I would like to download a website (html) and write it to an .html file with node and restler.
https://github.com/danwrong/Restler/
Their initial example is already halfway there:
var sys = require('util'),
rest = require('./restler');
rest.get('http://google.com').on('complete', function(result) {
if (result instanceof Error) {
sys.puts('Error: ' + result.message);
this.retry(5000); // try again after 5 sec
} else {
sys.puts(result);
}
});
Instead of sys.puts(result);
, I would need to save it to a file.
I am confused if I need a Buffer
, or if I can write it directly to file.