Skip to content

Instantly share code, notes, and snippets.

@molant
Created April 29, 2013 16:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save molant/5482576 to your computer and use it in GitHub Desktop.
Save molant/5482576 to your computer and use it in GitHub Desktop.
Problem with cookie handling and some websites
"use strict";
var request = require('request'),
request = request.defaults({
// jar: false,
headers: {
'Accept': 'text/html, application/xhtml+xml, */*',
'Accept-Language': 'en-US,en;q=0.5',
'User-Agent': 'Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; WOW64; Trident/6.0)'}}),
websites = ['http://cnet.com',
'http://walmart.com',
'http://cnet.com'],
i = 0,
max = websites.length;
function next() {
if (i < max) {
request(websites[i], function (err, res, body) {
console.log(i + ' ' + (res ? res.statusCode : err) + ' ' + (res ? res.request.href : websites[i]));
i++;
next();
});
} else {
console.log('finished');
}
}
next();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment