我成功地使用导体框架从网站上抓取数据。我使用 Chrome 浏览器,因此我在项目的根目录中安装了 chromedriver.exe。
为了加快速度,我想用 headless PhantomJS 浏览器替换 Chrome。我按照 Stackoverflow 问题的答案中的说明安装了 PhantomJS:PhantomJS & Conductor Framework并在@Config 中将浏览器更改为 Browser.PHANTOMJS。
然而,无论我做什么,我都没有结果。
我没有找到有关如何设置 PhantomJS 以与 Selenium 或 PhantomJS 一起使用的文档。
问题How to Implement Selenium WebDriver with PhantomJS and Can we Use Sikuli with PhantomJS?也没有帮助。
如何用 PhantomJS 替换 Chrome 以与 Selenium 和 Conductor 一起使用?
最佳答案
您遇到的问题似乎是由于 Conductor 中包含的 PhantomJS 库版本较旧。运行PhantomJS时的错误可以在this imported issue中找到在 Selenium Github 上。补救方法是导入一个 fork PhantomJS 与新版本的 Selenium 配合使用。
您可以通过编辑 pom.xml
轻松实现这一点。文件和交换
<groupId>com.github.detro</groupId>
<artifactId>phantomjsdriver</artifactId>
<version>${phantomjs_version}</version>
和
<groupId>com.codeborne</groupId>
<artifactId>phantomjsdriver</artifactId>
<version>1.2.1</version>
关于selenium - 如何用 PhantomJS 替换 Chrome 以与 Selenium 和 Conductor 一起使用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39870509/