secret
anonymous / node_img_dl.js
Created

Download multiple files node.js

  • Download Gist
node_img_dl.js
JavaScript
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
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();
});
});
 
}

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.