Skip to content

Instantly share code, notes, and snippets.

@veltman
Created November 13, 2013 20:06
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 veltman/7455488 to your computer and use it in GitHub Desktop.
Save veltman/7455488 to your computer and use it in GitHub Desktop.
var http = require("http");
var urls = process.argv.slice(2).map(function(d){
return {"url": d, "content": null};
});
process.argv.slice(2).forEach(function(url){
http.get(url,function(request){
var total = "";
request.on("data",function(data){
total += data.toString();
});
request.on("end",function(){
urls[urls.map(function(u){
return u.url;
}).indexOf(url)].content = total;
var numComplete = urls.filter(function(u){
return u.content !== null;
}).length;
if (numComplete == urls.length) {
urls.forEach(function(u){
console.log(u.content);
});
}
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment