Reputation: 633
I am trying to process the log from a specific webpage. Are there any suggestions how to retrieve the logs and put into text file from any web page using CasperJS?
Upvotes: 1
Views: 85
Reputation: 61892
You can use the remote.message
event to receive all console.log()
from the page. Using that, you can write them into a file using PhantomJS' fs module (fs.write()
).
var fs = require('fs');
casper.on("remote.message", function(msg){
fs.write("file", msg+"\n", "a");
});
...
Upvotes: 0
Reputation: 464
//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);
}
Upvotes: 0