java.lang.NoClassDefFoundError: org/openqa/selenium/browserlaunchers/Proxies
version:0.7.4
`
<dependency>
<groupId>us.codecraft</groupId>
<artifactId>webmagic-extension</artifactId>
<version>${webmagic.version}</version>
</dependency>
<dependency>
<groupId>us.codecraft</groupId>
<artifactId>webmagic-selenium</artifactId>
<version>${webmagic.version}</version>
</dependency>
config.ini配置:
What WebDriver to use for the tests
driver=phantomjs #driver=firefox ; driver=chrome #driver=http://localhost:8910 #driver=http://localhost:4444/wd/hub
PhantomJSspecific config (change according to your installation)
#phantomjs_exec_path=/Users/detro/bin/phantomjs-qt5 phantomjs_exec_path=/Users/detro/bin/phantomjs-upstream phantomjs_driver_path=../../src/main.js phantomjs_driver_loglevel=DEBUG
需要使用phtomjs进行抓取。
报错如下:
Exception in thread "pool-1-thread-1" java.lang.NoClassDefFoundError: org/openqa/selenium/browserlaunchers/Proxies
at org.openqa.selenium.phantomjs.PhantomJSDriverService.createDefaultService(PhantomJSDriverService.java:178)
at org.openqa.selenium.phantomjs.PhantomJSDriver.
有大佬知道怎么回事吗?
解决了,记录一下。 原因是phantomjs用的是com.codeborne.phantomjsdriver这个比较老了和webmagic的selenium不兼容,需要使用新的phantomjsdriver 修改如下
<dependency>
<groupId>com.codeborne</groupId>
<artifactId>phantomjsdriver</artifactId>
<version>1.4.4</version>
</dependency>
<dependency>
<groupId>us.codecraft</groupId>
<artifactId>webmagic-selenium</artifactId>
<version>${webmagic.version}</version>
<exclusions>
<exclusion>
<groupId>com.github.detro</groupId>
<artifactId>phantomjsdriver</artifactId>
</exclusion>
</exclusions>
</dependency>