PhantomJS无法打开HTTPS站点 [英] PhantomJS failing to open HTTPS site

查看:355
本文介绍了PhantomJS无法打开HTTPS站点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用以下基于loadspeed.js示例的代码来打开一个https://站点,该站点也需要http服务器身份验证。

I'm using the following code based on loadspeed.js example to open up a https:// site which requires http server authentication as well.

var page = require('webpage').create(), system = require('system'), t, address;

page.settings.userName = 'myusername';
page.settings.password = 'mypassword';

if (system.args.length === 1) {
    console.log('Usage: scrape.js <some URL>');
    phantom.exit();
} else {
    t = Date.now();
    address = system.args[1];
    page.open(address, function (status) {
        if (status !== 'success') {
            console.log('FAIL to load the address');
        } else {
            t = Date.now() - t;
            console.log('Page title is ' + page.evaluate(function () {
                return document.title;
            }));
            console.log('Loading time ' + t + ' msec');
        }
        phantom.exit();
    });
}  

无法一直加载页面。这可能有什么问题?安全网站是否有不同的处理方式?该网站可以通过浏览器成功访问。

Its failing to load the page all the time. What could be wrong here? Are secured sites to be handled any differently? The site can be accessed successfully from browser though.

我现在刚开始使用Phantom并发现即使我不动也要停止玩游戏转发这个问题。

I'm just starting with Phantom right now and find it too good to stop playing around even though i'm not moving forward with this issue.

推荐答案

我尝试了Fred和Cameron Tinker的答案,但只有 - ssl-protocol = any 选项似乎对我有帮助:

I tried Fred's and Cameron Tinker's answers, but only --ssl-protocol=any option seem to help me:

phantomjs --ssl-protocol=any test.js

另外我认为使用 - ssl-protocol = any 因为你仍在使用加密,但 - ignore-ssl-errors = true 将忽略(duh)所有ssl错误,包括恶意错误。

Also I think it should be way safer to use --ssl-protocol=any as you still are using encryption, but --ignore-ssl-errors=true will ignore (duh) all ssl errors, including malicious ones.

这篇关于PhantomJS无法打开HTTPS站点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆