Write results into a file using CasperJS

var fs = require('fs');
fs.write(myfile, myData, 'w');

for saving daily scrapes I do:

var currentTime = new Date();
var month = currentTime.getMonth() + 1;
var day = currentTime.getDate();
var year = currentTime.getFullYear();
var myfile = "data-"+year + "-" + month + "-" + day+".html";

Leave a Comment