I am using selenium with PhantomJs to scrape the URL. I initialized the driver as below
我正在使用Selenium和PhantomJs来刮取URL。我将驱动程序初始化如下
final DesiredCapabilities caps = DesiredCapabilities.chrome();caps.setCapability( PhantomJSDriverService.PHANTOMJS_EXECUTABLE_PATH_PROPERTY, "PhantomJsPath");caps.setCapability("page.settings.loadImages", false);caps.setCapability("trustAllSSLCertificates", true);RemoteWebDriver driver = new PhantomJSDriver(caps);driver.setLogLevel(Level.OFF);driver.get("https://.......")
The pagesource obtained from the driver is empty
从驱动程序获取的页面源是空的
Am I missing anything?
我错过了什么吗?
1 个解决方案
#1
Recently the POODLE vulnerability forced websites to remove SSLv3 support. Since PhantomJS < v1.9.8 uses SSLv3 by default, the page cannot be loaded. To fix this, you would need to run PhantomJS with --ssl-protocol=tlsv1
or --ssl-protocol=any
. See this answer for plain PhantomJS.
最近,POODLE漏洞迫使网站删除SSLv3支持。由于PhantomJS
caps = DesiredCapabilities.phantomjs(); // or new DesiredCapabilities();caps.setCapability(PhantomJSDriverService.PHANTOMJS_CLI_ARGS, new String[] {"--ssl-protocol=tlsv1"});// other capabilitiesdriver = new PhantomJSDriver(caps);
If this doesn't solve the issue, you can also add
如果这不能解决问题,您也可以添加
"--web-security=false", "--ignore-ssl-errors=true"
to the String array of cli args as seen in SiKing's answer here.
在SiKing的答案中可以看到cli args的String数组。
#1
Recently the POODLE vulnerability forced websites to remove SSLv3 support. Since PhantomJS < v1.9.8 uses SSLv3 by default, the page cannot be loaded. To fix this, you would need to run PhantomJS with --ssl-protocol=tlsv1
or --ssl-protocol=any
. See this answer for plain PhantomJS.
最近,POODLE漏洞迫使网站删除SSLv3支持。由于PhantomJS
caps = DesiredCapabilities.phantomjs(); // or new DesiredCapabilities();caps.setCapability(PhantomJSDriverService.PHANTOMJS_CLI_ARGS, new String[] {"--ssl-protocol=tlsv1"});// other capabilitiesdriver = new PhantomJSDriver(caps);
If this doesn't solve the issue, you can also add
如果这不能解决问题,您也可以添加
"--web-security=false", "--ignore-ssl-errors=true"
to the String array of cli args as seen in SiKing's answer here.
在SiKing的答案中可以看到cli args的String数组。