1
我正在尝试处理来自特定网页的日志。是否有任何建议如何使用CasperJS从任何网页检索日志并放入文本文件?如何检索浏览器Web控制台日志并将其写入文件?
我正在尝试处理来自特定网页的日志。是否有任何建议如何使用CasperJS从任何网页检索日志并放入文本文件?如何检索浏览器Web控制台日志并将其写入文件?
可以使用remote.message
事件从页面接收所有console.log()
。使用它,您可以使用PhantomJS的fs模块(fs.write()
)将它们写入文件。
var fs = require('fs');
casper.on("remote.message", function(msg){
fs.write("file", msg+"\n", "a");
});
...
//Keep a reference to the original function
var original = console.log;
//Override the function
console.log = function(arg) {
//Do what you want with the arguments of the function
....
//Call the original function
original.call(this, arguments);
}
如果他们记录到_Console_那么你可以_shadow_'console.log'等 –