Skip to content

Instantly share code, notes, and snippets.

@veltman
Created December 26, 2013 21:53
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/8139188 to your computer and use it in GitHub Desktop.
Save veltman/8139188 to your computer and use it in GitHub Desktop.
var cities = ["Albuquerque","Austin","Baltimore","Boston","Charlotte","Chicago","Columbus","Dallas","Denver","Detroit","El Paso","Fairbanks","Fort Worth","Fresno","Houston","Indianapolis","Jacksonville","Kansas City","Las Vegas","Long Beach","Los Angeles","Louisville","Memphis","Mesa","Milwaukee","Nashville","New York","Oklahoma City","Philadelphia","Phoenix","Portland","Sacramento","San Antonio","San Diego","San Francisco","San Jose","Seattle","Tucson","Washington"];
var output = {};
var http = require('http');
var fs = require('fs');
var download = function(url, dest, cb) {
var file = fs.createWriteStream(dest);
var request = http.get(url, function(response) {
response.pipe(file);
file.on('finish', function() {
file.close();
cb();
});
});
};
cities.forEach(function(d){
download("http://joannaskao.com/projects/whitechristmas/data/"+encodeURIComponent(d)+"-min.json","data/"+d.replace(" ","_")+".json",function(){
console.log("Downloaded "+d);
});
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment