Phantomjs 与 Facebook 的连接无法通过 SSL 握手



我正在尝试使用phantomjs为Facebook构建一个网络爬虫。由于 SSL 握手失败,连接失败。我在推特上得到了相同的结果,但谷歌工作正常。有谁知道解决方案?我正在运行 phantomjs 版本 1.9.7。我已经在下面发布了我的代码和错误输出。

var system = require('system');
var page = require('webpage').create();
page.open('https://www.facebook.com', function(status){
    console.log("status: " + status);
    if(status === "success"){
        console.log("no error");
    } else {
        console.log("Error opening url "" + page.reason_url + "": " + page.reason);
    }
    phantom.exit();
});

输出:

unable to load url: "https://www.facebook.com/"
error code: 6, description: SSL handshake failed
status: fail
Error opening url "undefined": undefined

phantomjs 在使用 https 时默认为 SSL 3.0。由于 SSL 3.0 在很多主机上被禁用,因为它不安全,SSL 握手将失败。使用 phantomjs --ssl-protocol=any 使 phantomjs 使用更现代的版本(TLS1.0 或更高版本)。