Is it possible to essentially run a wget
from within a node.js app? I'd like to have a script that crawls a site, and downloads a specific file, but the href
of the link that goes the file changes fairly often. So, I figured the easiest way to go about doing it would be to find the href
of the link, then just perform a wget on it.
Thanks!
You can run an external command using child_processes:
var util = require('util'),
exec = require('child_process').exec,
child,
url = 'url to file';
child = exec('wget ' + url,
function (error, stdout, stderr) {
console.log('stdout: ' + stdout);
console.log('stderr: ' + stderr);
if (error !== null) {
console.log('exec error: ' + error);
}
});