Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Write results into a file using CasperJS

How do I create a file in the file system and place the contents of this.getPageContent() inside it?

like image 456
narek Avatar asked Oct 10 '12 19:10

narek


1 Answers

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"; 
like image 59
Henry Avatar answered Oct 19 '22 09:10

Henry