How do I create a file in the file system and place the contents of this.getPageContent() inside it?
A full 'then' function, that scrap data from a site, returns a json and store it to a file"myFile" should looks like this:
casper.then(function paso2() {
var jsonStr = this.evaluate(function(){
var puntos = {};
puntos.alafecha = document.querySelector('div.cont_item_productos_puntos > p.txt_negro').textContent;
puntos.totales = document.querySelector('ul.lista_prod_puntos > li.ppuntos_1 > span.ppuntos_2').textContent;
return JSON.stringify(puntos);
});
console.log("this is a response in json format: "+json);
fs.write('myFile.json', jsonStr, 'w');
});