即使使用--ssl-protocol = any,CasperJS / PhantomJS也无法在某些站点上进行SSL握手

时间:2015-04-03 23:40:19

标签: javascript ssl web-scraping phantomjs casperjs

我遇到了CasperJS和SSL的问题,但使用--ssl-protocol = any始终解决了问题,如this回答中所述。在这种情况下,我仍然有问题。

我把它放在命令行中:

casperjs --ssl-protocol=any --ignore-ssl-errors=true sanity.js

这是sanity.js:

 var casper = require('casper').create({
    verbose: true,
    logLevel: 'debug'
});

casper.on("resource.error", function(resourceError){
    console.log('Unable to load resource (#' + resourceError.id + 'URL:' + resourceError.url + ')');
    console.log('Error code: ' + resourceError.errorCode + '. Description: ' + resourceError.errorString);
});

casper.start('https://www.google.com/', function() {
    this.echo(this.getTitle());
});

casper.thenOpen('https://www.zazzle.com/lgn/signin', function() {
    this.echo(this.getTitle());
});

casper.run();

第一个网址加载正常。但是第二个SSL握手失败了。调试输出:

[info] [phantom] Starting...
[info] [phantom] Running suite: 4 steps
[debug] [phantom] opening url: https://www.google.com/, HTTP GET
[debug] [phantom] Navigation requested: url=https://www.google.com/, type=Other, willNavigate=true, isMainFrame=true
[debug] [phantom] url changed to "https://www.google.com/"
[debug] [phantom] Successfully injected Casper client-side utilities
[info] [phantom] Step anonymous 2/4 https://www.google.com/ (HTTP 200)
Google
[info] [phantom] Step anonymous 2/4: done in 876ms.
[debug] [phantom] opening url: https://www.zazzle.com/lgn/signin, HTTP GET
[debug] [phantom] Navigation requested: url=https://www.zazzle.com/lgn/signin, type=Other, willNavigate=true, isMainFrame=true
Unable to load resource (#9URL:https://www.zazzle.com/lgn/signin)
Error code: 6. Description: SSL handshake failed
[warning] [phantom] Loading resource failed with status=fail: https://www.zazzle.com/lgn/signin
[info] [phantom] Step anonymous 4/4 https://www.google.com/ (HTTP 0)
Google
[info] [phantom] Step anonymous 4/4: done in 1178ms.
[info] [phantom] Done 4 steps in 1197ms

我正在运行PhantomJS版本1.9.7和CasperJS版本1.1.0-beta3。当涉及到SSL的细节时,我有点无能为力,但我无法找到解决这个问题的更多方法。任何帮助都会很棒!

0 个答案:

没有答案