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

查看:28
本文介绍了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天全站免登陆