如何更改PhantomJS版本 [英] How to change PhantomJS version

查看:101
本文介绍了如何更改PhantomJS版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在学习PhantomJS进行抓取.我开始合并CasperJS.当我运行CasperJS和文件名时,我会回来

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

如何更改PhantomJS版本以使用CasperJS?有没有更简便的方法来刮除JavaScript繁重的网站?

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

我用过cheerio并要求,但它们只能获取静态html.

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

推荐答案

如果您尝试将PhantomJS 2.x与CasperJS版本< = 1.1-beta一起使用,则会显示此消息.

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

如果您的系统上也有PhantomJS 1.x,则只需在命令提示符下更改可执行文件即可.

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

终端:

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

如果位于PATH中,也可以使用"phantomjs198"代替"/path/to/phantomjs198".

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

另一种方法是使用GitHub上master分支中的CasperJS(文档).根据我的经验,它效果很好,并且支持PhantomJS 2.x(和PhantomJS 1.x).

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

这篇关于如何更改PhantomJS版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆