Skip to content

Instantly share code, notes, and snippets.

@zhuangya
Created September 22, 2013 13:24
Show Gist options
  • Select an option

  • Save zhuangya/6659871 to your computer and use it in GitHub Desktop.

Select an option

Save zhuangya/6659871 to your computer and use it in GitHub Desktop.
var http = require('http');
var urls = process.argv.slice(2);
var bufferString = '';
var counter = 0;
var canContinue = true;
while(!!urls.length && canContinue) {
currentUrl = urls.shift();
http.get(currentUrl, function(req) {
req.setEncoding('utf-8');
req.on('data', function(res) {
canContinue = false;
bufferString = bufferString + res;
}).on('end', function() {
canContinue = true;
console.log(bufferString);
bufferString = '';
});
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment