-
-
Save anonymous/b803066a3540b6c16f53 to your computer and use it in GitHub Desktop.
Download multiple files node.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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