Last active
December 11, 2015 09:38
-
-
Save arisolt/4581300 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 async = require('async'), | |
array1 = [1, 2, 3], | |
array2 = ['stuff'], | |
cheerio = ['cheerio'], | |
httprequest = require('request'); | |
async.reduce(array1, array2, function (array2, item, callback) { | |
console.log("I've iterated " + item + "x"); | |
callback (array2.push( | |
function () {console.log("aa"); | |
var moreStuff = []; | |
return httprequest("http://dummywebsite.com?id=" + item, function () { | |
var $ = cheerio.load(body); | |
var count = 0; | |
return async.waterfall([ | |
function (callback) { | |
$('strong').each(function(i, elem) { | |
count++; | |
}); | |
callback(null, count); | |
}, | |
function (count2, callback) { | |
$('strong').each(function(i, elem) { | |
moreStuff.push($(this).text()); | |
if (i == count2 - 1) { | |
callback(null, moreStuff); | |
}; | |
}); | |
}], | |
function (err, result) { | |
return result; | |
}); | |
}); | |
} | |
)); | |
}, function (err, results){console.log(err);} | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment