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

查看:22
本文介绍了如何更改 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和require,但他们只得到静态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	ophantomjs198.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天全站免登陆