1

I'm trying to make a crawler for SEO purposes, and I can't seem to get PhantomJS to at least download this particular page: https://tablet.euroslots.com/home/

If I use cURL it works fine (but obviously doesn't process the javascript):

✓ 1344:0 /cherrytech/js-crawler root› curl https://tablet.euroslots.com/home/ <!doctype html><!--[if lt IE 7]><html class="no-js lt-ie9 lt-ie8 lt-ie7"> ... 

My PhantomJS script:

var page = require('webpage').create(); page.onResourceRequested = function (request) { console.log('Request ' + JSON.stringify(request, undefined, 4)); }; page.onResourceReceived = function(response) { console.log('Response (#' + response.id + ', stage "' + response.stage + '"): ' + JSON.stringify(response)); }; page.onResourceError = function(resourceError) { console.log('Unable to load resource (#' + resourceError.id + 'URL:' + resourceError.url + ')'); console.log('Error code: ' + resourceError.errorCode + '. Description: ' + resourceError.errorString); }; page.settings.userAgent = 'Mozilla/5.0 (iPad; CPU OS 6_0 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10A406 Safari/8536.25'; page.open('https://tablet.euroslots.com/home/', function() { console.log(page.content); phantom.exit(); }); 

And this is the result of running it:

✓ 1347:0 /cherrytech/js-crawler root› phantomjs crawler.js Request { "headers": [ { "name": "User-Agent", "value": "Mozilla/5.0 (iPad; CPU OS 6_0 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10A406 Safari/8536.25" }, { "name": "Accept", "value": "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8" } ], "id": 1, "method": "GET", "time": "2014-09-16T16:02:24.426Z", "url": "https://tablet.euroslots.com/home/" } Unable to load resource (#1URL:https://tablet.euroslots.com/home/) Error code: 2. Description: Connection closed Response (#1, stage "end"): {"contentType":null,"headers":[],"id":1,"redirectURL":null,"stage":"end","status":null,"statusText":null,"time":"2014-09-16T16:02:24.763Z","url":"https://tablet.euroslots.com/home/"} <html><head></head><body></body></html> 
4
  • You can also register to onResourceError. You will see that the connection is closed. I don't know why. --web-security=false and --ignore-ssl-errors=true does nothing. You can also try slimerjs instead of phantomjs. Maybe it is a phantomjs limitation Commented Sep 16, 2014 at 15:30
  • I've tried CasperJS and it does the same thing. ): Commented Sep 16, 2014 at 15:36
  • I've just updated the code to register to onResourceError Commented Sep 16, 2014 at 16:03
  • Try to upgrade Phantomjs eg 1.9.8 Commented Dec 7, 2014 at 0:45

1 Answer 1

5

Try calling phantomjs with --ssl-protocol=any

I had the same exact problem, with an external site that worked one week ago.

So I searched, and found a related issue described at Qt QNetworkReply connection closed. It helped me look into the phantomjs' embedded Qt: it defaults to forcing new connections in SSLv3, which is either too new for old sites, or too old for new sites (but was quite a reasonable default at the time Qt 4.8.4 was released).

With "any", you tell phantomjs to try all protocols, which should help you pass the test. It will try more-secure-than-SSLv3 protocols, but less-secure-than-SSLv3 too (SSLv3 is at middle range). So, if "any" works, you should then try to force a more-secure-than-SSLv3 value instead of letting "any". In my case, specifying --ssl-protocol=tlsv1 worked.

Guess that the recent issues with SSL (goto fail, heartbleed, poodle, and so on) made a whole lot of websites upgrade their servers, now refusing SSLv3 connections. But in case your server uses an older-than-SSLv3 protocol, keep the "any" (and all the security risks associated…).

Sign up to request clarification or add additional context in comments.

1 Comment

This should probably be 'the' answer. SSLv3 is a bad default since heartbleed!

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.