CasperJS
With the rising popularity of PhantomJS, there has been an evolution of several projects that integrate with or are based on PhantomJS. Some of these are extensions that enhance the scripting ability of PhantomJS.
CasperJS is an open source extension for PhantomJS. It extends the API of PhantomJS to make tasks such as web scraping, testing, and DOM manipulation easier. CasperJS can be downloaded from http://casperjs.org.
Let us see some basic PhantomJS and CasperJS code in action.
var casper = require("casper").create(); casper.start("http://www.phantomjs.org", function(){ this.echo(this.getTitle()); }); casper.run();
If you look closely at the previous code, there is no trace of any PhantomJS API code having been used, except for the require()
function.
CasperJS still uses PhantomJS and depends on the PhantomJS API; however, it provides its own unique API. CasperJS modules come with a new set of API functions. These functions introduce new features by wrapping...