Skip to content

Instantly share code, notes, and snippets.

/node_img_dl.js Secret

Created February 9, 2012 04:38
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 anonymous/b803066a3540b6c16f53 to your computer and use it in GitHub Desktop.
Save anonymous/b803066a3540b6c16f53 to your computer and use it in GitHub Desktop.
Download multiple files node.js
var fs=require('fs');
var http=require('http');
dl('/wikipedia/commons/1/15/Jagdschloss_Granitz_4.jpg','name.jpeg');
dl('/wikipedia/commons/9/93/Cold_Bay_Izembek_NWR.jpg','name2.jpeg');
function dl(path,file){
var f=fs.createWriteStream(file);
var options={
host:'upload.wikimedia.org',
port:80,
path:path
}
http.get(options,function(res){
res.on('data', function (chunk) {
f.write(chunk);
});
res.on('end',function(){
f.end();
});
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment