Skip to content

Instantly share code, notes, and snippets.

@JakubOboza
Created February 10, 2012 11:33
Show Gist options
  • Select an option

  • Save JakubOboza/1788925 to your computer and use it in GitHub Desktop.

Select an option

Save JakubOboza/1788925 to your computer and use it in GitHub Desktop.
guts out
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