How to change PhantomJS version

后端 未结 1 908
醉梦人生
醉梦人生 2020-12-22 08:43

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


        
相关标签:
1条回答
  • 2020-12-22 09:16

    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).

    0 讨论(0)
提交回复
热议问题