I am just getting started with JS and Node.js. I am trying to build a simple scraper as first project, using Node.js and some modules such as request
and cheerio
.
I would like to add a 5 secs delay between each http request for each domain contained into the array. Can you explain me how to do it?
Here is my code:
var request = require('request');
var arr = [ "http://allrecipes.com/", "http://www.gossip.fr/" ];
for(var i=0; i < arr.length; i++) {
request(arr[i], function (error, response, body){
console.log('error:', error);
console.log('statusCode:', response && response.statusCode);
console.log('body:', body);
});
}