admin管理员组文章数量:1241128
When I use download() in CasperJS, I get a file saved in the system, but the file doesn't contain the actual source code of the webpage. It just contains a link to the remote page. How can I dump the source code of webpage into a local file using CasperJs? getHTML() is also only echoing the contents onto the terminal. How to save the contents to a file?
When I use download() in CasperJS, I get a file saved in the system, but the file doesn't contain the actual source code of the webpage. It just contains a link to the remote page. How can I dump the source code of webpage into a local file using CasperJs? getHTML() is also only echoing the contents onto the terminal. How to save the contents to a file?
Share Improve this question asked Jan 24, 2014 at 18:00 whizvidswhizvids 2482 silver badges8 bronze badges 2- Maybe this link could help : darrendev.blogspot.fr/2013/11/… – Brice Favre Commented Jan 25, 2014 at 20:04
- 1 possible duplicate of Write results into a file using Casper JS – Brice Favre Commented Jan 25, 2014 at 20:05
2 Answers
Reset to default 11First import file system library
var fs = require('fs');
Extract html
var html = this.getHTML();
// or
var html = this.getPageContent();
Copy into a file
var f = fs.open('/path/to/your/file', 'w');
f.write(html);
f.close();
do just: fs.write('path/to/file', 'your string', 'w');
in this case you don't need open and close a file
本文标签: javascriptDumping Source Code into a local file using CasperJSStack Overflow
版权声明:本文标题:javascript - Dumping Source Code into a local file using CasperJS - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1740073170a2223157.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论