Created
March 25, 2014 04:23
-
-
Save gabhi/9755243 to your computer and use it in GitHub Desktop.
web page scraping using request cheerio nodejs
This file contains 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 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