Write results into a file using CasperJS

后端 未结 4 2003
一生所求
一生所求 2020-12-13 06:08

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

4条回答
  •  温柔的废话
    2020-12-13 06:58

    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";
    

提交回复
热议问题