Created
March 20, 2014 20:40
-
-
Save adamrights/9673352 to your computer and use it in GitHub Desktop.
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
/* | |
* Cheerio, A test for crawling anchors on a site. | |
*/ | |
var request = require('request'); | |
var cheerio = require('cheerio'); | |
var async = require('async'); | |
var jar = request.jar(); | |
request({ | |
followRedirect: true, | |
uri: process.env.LINKS_FOR || 'https://news.ycombinator.com', | |
timeout: 10000, | |
jar: jar | |
}, function requestCallback(err, res, body) { | |
var $; | |
$ = cheerio.load(body); | |
console.log(body) | |
console.log('-----------------------------------------') | |
console.log('---End of HTTP BODY RESPONSE-------------') | |
console.log('--------Parsed Anchor Links Below--------') | |
return $('a').each(function() { | |
return console.log("" + ($(this).text()) + " -> " + ($(this).attr('href'))); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment