Created
February 10, 2012 11:33
-
-
Save JakubOboza/1788925 to your computer and use it in GitHub Desktop.
guts out
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var site_url = 'http://www.pudelek.pl/'; | |
| var default_headers = { | |
| 'User-Agent': 'Mozilla/5.0 (X11; Linux i686; rv:7.0.1) Gecko/20100101 Firefox/7.0.1', | |
| 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', | |
| 'Accept-Language': 'en-us,en;q=0.5', | |
| 'Accept-Charset': 'ISO-8859-1,utf-8;q=0.7,*;q=0.7', | |
| 'Cache-Control': 'max-age=0' | |
| }; | |
| request({ url: site_url, headers: default_headers, method: 'GET' }, function (err, res, body) { | |
| if (!err && res.statusCode == 200) { | |
| document = jsdom.jsdom(body), | |
| window = document.createWindow(); | |
| jsdom.jQueryify(window, jquery_path , function() { | |
| var headings = []; | |
| window.$(".entry").each(function(i, e){ | |
| var el = window.$(e).find(".header h3 a"); | |
| headings.push({href: el.attr('href'), title: el.text()} ) | |
| }); | |
| response({data:headings, name: "test"}); | |
| }); | |
| } | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment