Skip to content

Instantly share code, notes, and snippets.

@syohex
Created January 15, 2012 13:33
Show Gist options
  • Save syohex/1615874 to your computer and use it in GitHub Desktop.
Save syohex/1615874 to your computer and use it in GitHub Desktop.
Simple download with node.js
var request = require('request');
var fs = require('fs');
var downloadUrl = process.argv[2];
if (typeof donwloadUrl === undefined) {
console.log("Usage: request.js URL");
process.exit(1);
}
request.get({ uri: downloadUrl }, function (error, response, body) {
if (!error && response.statusCode === 200) {
fs.createWriteStream("output.html", {
flags: "w",
}).write(body);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment