Skip to content

Instantly share code, notes, and snippets.

@gabhi
Created March 25, 2014 04:23
Show Gist options
  • Save gabhi/9755243 to your computer and use it in GitHub Desktop.
Save gabhi/9755243 to your computer and use it in GitHub Desktop.
web page scraping using request cheerio nodejs
var request = require('request');
var cheerio = require('cheerio');
var searchTerm = 'screen+scraping';
var url = 'http://www.bing.com/search?q=' + searchTerm;
request(url, function(err, resp, body){
$ = cheerio.load(body);
links = $('.sb_tlst h3 a'); //use your CSS selector here
$(links).each(function(i, link){
console.log($(link).text() + ':\n ' + $(link).attr('href'));
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment