您好我使用phantomJS和selenuim从网站获取一些信息。
我使用的版本:
<dependency>
<groupId>com.github.detro.ghostdriver</groupId>
<artifactId>phantomjsdriver</artifactId>
<version>1.1.0</version>
<exclusions>
<exclusion>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
</exclusion>
<exclusion>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-remote-driver</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>2.43.0</version>
</dependency>
到init驱动程序我使用:
File phantomjs = Phanbedder.unpack();
// Create the driver
DesiredCapabilities dcaps = new DesiredCapabilities();
dcaps.setCapability(PhantomJSDriverService.PHANTOMJS_EXECUTABLE_PATH_PROPERTY, phantomjs.getAbsolutePath());
dcaps.setCapability(
PhantomJSDriverService.PHANTOMJS_PAGE_SETTINGS_PREFIX + "userAgent",
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) AppleWebKit/537.11 (KHTML, like Gecko) " +
"Chrome/23.0.1271.97 Safari/537.11"
);
dcaps.setCapability(PhantomJSDriverService.PHANTOMJS_CLI_ARGS, new String[] {"--web-security=no", "--ignore-ssl-errors=yes", "--ssl-protocol=TLSv1"});
dcaps.setBrowserName(BrowserType.FIREFOX_CHROME);
dcaps.setPlatform(Platform.UNIX);
dcaps.setJavascriptEnabled(true);
driver = new PhantomJSDriver(dcaps);
driver.setLogLevel(Level.ALL);
当我想到任何网站时,我得到未定义的结果:
driver.get(url1);
System.out.println("Browsing URL page Accueil : " + driver.getCurrentUrl());
我进入控制台浏览URL页面Accueil:about:blank
请帮助,谢谢。
答案 0 :(得分:0)
感谢http://www.markbetz.net/2014/11/10/phantomjs-aboutblank-and-ssl-protocol/comment-page-1/
解决方案是添加能力“--ssl-protocol = any”