How to change PhantomJS version

1k Views Asked by At

I am learning PhantomJS for scraping. I started to incorporate CasperJS. When I run CasperJS and the filename I get back

CasperJS needs PhantomJS v1.x

How do you change the PhantomJS version to use CasperJS? Is there an easier way to scrape a website that is heavy javascript?

I used cheerio and require but they only get static html.

1

There are 1 best solutions below

3
On BEST ANSWER

This message is shown if you try to use PhantomJS 2.x with a CasperJS version <= 1.1-beta.

use different PhantomJS once

If you also have PhantomJS 1.x on your system, you can simply change the executable like this in the command prompt.

cmd.exe:

C:\path> set PHANTOMJS_EXECUTABLE=C:\path\to\phantomjs198.exe

C:\path> casperjs script.js

terminal:

$ export PHANTOMJS_EXECUTABLE=/path/to/phantomjs198
$ casperjs script.js

You can also use "phantomjs198" instead of "/path/to/phantomjs198" if it is in PATH.

Update CasperJS

The other way would be to use the CasperJS from the master branch on GitHub (docs). It works rather well in my experience and supports PhantomJS 2.x (and PhantomJS 1.x).