0

I'm new to phantomjs and I'm testing with version 2.5.0-development. I used the script screen.js it works well with http://phantomjs.org and https://google.com but does not work with https://globo.com and https://uol.com.br I can not understand what I do wrong no error appears.

screen.js

var page = require('webpage').create(); page.open('https://www.globo.com', function() { page.render('globo.png'); phantom.exit(); }); 

Edit: I tried the old version 2.1.1 and it worked. The problem seems to be the version.

2 Answers 2

1

As mentioned on the phantomjs page - http://phantomjs.org/ - PhantomJS development was stopped, and it's pretty much obsolete at this point in time. PhantomJS is basically equivalent to a 6-7 year old browser, doesn't support a lot of current JS/CSS (let, const, flexbox, grid layout, etc), and has the nasty habit of not raising errors when unsupported JS features (like let or const) are used in an asset of the page and instead just ignoring those JS files. You're going to be much better off switching to something more modern like headless Chrome.

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

5 Comments

It may not be a hasty habit rather just being in line with IE8 compatible browser, jk
I tried chrome but it was very slow. I'll try it for a second time.
@BrunoAndrade slow is sometimes better than unusable
@BrunoAndrade Since a headless browser wasn't mentioned in the answer, here is a Google maintained headless browser: npmjs.com/package/puppeteer
@GetOffMyLawn puppeteer isn’t a browser - it’s a JS interface to Chrome/Chromium
0

I think you must need to wait a bit before page loads. Try adding a set timeout, for example:

var page = require('webpage').create(); page.open('https://www.globo.com', function() { setTimeout(function(){ page.render('globo.png'); phantom.exit(); }, 5000); // Change timeout as required to allow sufficient time }); 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.