Reliably detecting PhantomJS-based spam bots

I very much share your take on CAPTCHA. I’ll list what I have been able to detect so far, for my own detection script, with similar goals. It’s only partial, as they are many more headless browsers. Fairly safe to use exposed window properties to detect/assume those particular headless browser: window._phantom (or window.callPhantom) //phantomjs window.__phantomas … Read more

console.log doesn’t work in CasperJS’ evaluate with setTimeout

Because you’re mixing up casperjs and remote page environments. The evaluate function will execute code within the remote page env, so the console.log call won’t output anything. If you want to catch remote console.log calls, listen to the remote.message event: casper.on(‘remote.message’, function(msg) { this.echo(‘remote message caught: ‘ + msg); }) Btw, documentation for events is … Read more

How do I access an iframe from CasperJS?

Spent forever looking for this, and of course I found the answer minutes after posting the question. I can use the new frame switching commands added to phantomjs in this commit. Specifically, the this.page.switchToChildFrame(0) and this.page.switchToParentFrame() functions. It appears undocumented, and it also seems that the methods have been changed for upcoming releases, but it … Read more

What must be wrapped in then() statements in CasperJS? How to determine execution order of sync/async functions?

Rule of thumb: All CasperJS functions which contain the words then and wait are asynchronous. This statement has many exceptions. What is then() doing? CasperJS is organized as a series of steps that handle the control flow of your script. then() handles the many PhantomJS/SlimerJS event types that define the ending of a step. When … Read more