问题
I am trying to build a web scraper for Facebook using phantomjs. The connection fails due to SSL handshake failure. I get the same result for twitter, but google works fine. Does anyone know a solution for this? I am running phantomjs version 1.9.7. I have posted my code and my error output below.
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();
});
output:
unable to load url: "https://www.facebook.com/"
error code: 6, description: SSL handshake failed
status: fail
Error opening url "undefined": undefined
回答1:
phantomjs defaults to SSL 3.0 when using https. Since SSL 3.0 is disabled on lots of hosts because it is insecure, the SSL handshake will fail. Use phantomjs --ssl-protocol=any
to make phantomjs use a more modern version (TLS1.0 or higher).
来源:https://stackoverflow.com/questions/29058557/phantomjs-connection-to-facebook-fails-ssl-handshake