Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PhantomJS failing to open HTTPS site

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.

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.

like image 418
Sreerag Avatar asked Aug 18 '12 19:08

Sreerag


1 Answers

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 

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.

like image 156
JLarky Avatar answered Sep 19 '22 09:09

JLarky