2.2.6 • Published 4 years ago

dsoup v2.2.6

Weekly downloads
2
License
ISC
Repository
github
Last release
4 years ago

dsoup

server

require('dsoup')();

jquery

var serverUrl = 'http://127.0.0.1:8080';

(function(context, server){
    var parseHTML = function(html) {
        return new DOMParser().parseFromString(html, 'text/html');
    };
    context.extend({
        dsoup: function(url, callback) {
            context.post(server, {url, url}, function(response) {
                response.data.content = parseHTML(response.data.content);
                if(response.code == 200) {
                    callback && callback(response.data.content,
                        response.data);
                    return;
                }
                throw new Error('request error');
            })
        }
    });
})($, serverUrl);

example

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Example</title>
    <script src="jquery.js"></script>
    <script src="dsoup.jquery.js"></script>
</head>
<body>
    <h1>loading...</h1>
</body>
<script>
    var h1 = document.getElementsByTagName('h1')[0];
    $.dsoup('http://www.google.com', function(dom) {
        h1.innerText = $(dom).find('title').text();
    });
</script>
</html>
2.2.6

4 years ago

2.2.5

4 years ago

2.2.4

4 years ago

2.2.3

4 years ago

2.2.2

4 years ago

2.2.1

4 years ago

2.2.0

4 years ago

2.1.9

4 years ago

2.1.8

4 years ago

2.1.7

4 years ago

2.1.4

4 years ago

2.1.3

4 years ago

2.1.6

4 years ago

2.1.5

4 years ago

2.1.2

4 years ago

2.1.1

4 years ago

2.1.0

4 years ago

2.0.4

4 years ago

2.0.3

4 years ago

2.0.2

4 years ago

2.0.1

4 years ago

2.0.0

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago