I use PhantomJS to get the page content for a given URL. The problem is that on some pages PhantomJS cannot load some resources (js, css ...), and the error I get is this:
error code 5, operation canceled
The web page on which I can reproduce this problem, www.lifehacker.com The
resources that I cannot get are the following:
The command that I run:
phantomjs --debug=true --cookies-file=cookies.txt --ignore-ssl-errors=true --ssl-protocol=tlsv1 fetchpage.js http://www.lifehacker.com
and even if I delete the settings, such as cookies, ignore-ssl-errors, ssl-protocol, the result is still the same.
Fetchpage.js script file:
var webPage = require('webpage');
var system = require('system');
var page = webPage.create();
if (system.args.length === 1) {
console.log('Usage: fetchpage.js <some URL>');
phantom.exit(1);
}
var url = system.args[1];
page.open(url, function (status) {
console.log("STATUS: " + status);
if (status !== 'success') {
console.log(
"Error opening url \"" + page.reason_url
+ "\": " + page.reason
+ "\": " + page
);
phantom.exit(1);
} else {
var content = page.content;
console.log(content);
phantom.exit(1);
}
});
Chrome, . , URL- , phantomjs Chrome, .
Google , -, .
phantomjs v1.9.0, 1.9.8 2.0.1-development.
, phantomjs script , , . phantomjs :
...
var page = webPage.create();
page.customHeaders = {
"Cache-Control":"no-cache",
"Pragma":"no-cache"
};
page.open(url, function (status) {
...
.
.