Created
January 20, 2013 13:04
-
-
Save geNAZt/4578504 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
var req = require('request'), | |
cheerio = require('cheerio'), | |
async = require('async'), | |
urls = ["http://google.com/", "http://test.de/", "http://bild.de/"]; | |
function crawlUrl(url, callback) { | |
"use strict"; | |
var array = []; | |
req(url, function (error, response, body) { | |
var $ = cheerio.load(body); | |
$('strong').length; | |
$('strong').each(function (i, item) { | |
array.push($(this).text()); | |
if (i === $('strong').length) { | |
callback(null, array); | |
} | |
}); | |
}); | |
} | |
async.map(urls, crawlUrl, function (err, results) { | |
"use strict"; | |
console.log(results); | |
// results is now an array of the array for each url | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment