Created
December 6, 2012 03:36
-
-
Save nickdesaulniers/4221609 to your computer and use it in GitHub Desktop.
temp variable
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 urls = ['google.com', 'youtube.com', 'cracked.com']; | |
var fs = require('fs'), | |
http = require('http'), | |
url = require('url'), | |
path = require('path'); | |
var count = 0; | |
urls.map(url.parse).forEach(function (url) { | |
http.get(url, function (res) { | |
var fname = path.basename(url.path); | |
var file = fs.createWriteStream('musika/' + fname); | |
res.on('data', function (data) { | |
res.pipe(file); | |
}).on('end', function () { | |
console.log('Download complete (' + ++count + '/' + urls.length + '): ' + fname); | |
file.end(); | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment