phantomJS webpage timeout

PhantomJS 1.9 has introduced a new setting, resourceTimeout, that controls how long a request can take before it gets cancelled. Along with that, there’s a onResourceTimeout event that is triggered if/when a request times out. Here’s a code snippet illustrating all of the above: var page = require(‘webpage’).create(); page.settings.resourceTimeout = 5000; // 5 seconds page.onResourceTimeout … Read more

PhantomJS fails to open local file

PhantomJS can open local files without any problems. The url have to follow classic Url/Uri rules, especially for a local file. /Full/Path/To/test.html is not valid for PhantomJS. Is it a local file or a web resource? Depending of the path, just try with something like this: file:///C:/Full/Path/To/test.html or if it’s hosted in a web server: … Read more

Debugging PhantomJS webpage.open failures

Found this post which explains how to set up callbacks to get at the underlying reason for the failure: http://newspaint.wordpress.com/2013/04/25/getting-to-the-bottom-of-why-a-phantomjs-page-load-fails/ Based on the that page, you could print out errors as follows: page.onResourceError = function(resourceError) { console.error(resourceError.url + ‘: ‘ + resourceError.errorString); }; The page goes on to show an example of detailed logging for … Read more

How can I control PhantomJS to skip download some kind of resource?

UPDATED, Working! Since PhantomJS 1.9, the existing answer didn’t work. You must use this code: var webPage = require(‘webpage’); var page = webPage.create(); page.onResourceRequested = function(requestData, networkRequest) { var match = requestData.url.match(/wordfamily.js/g); if (match != null) { console.log(‘Request (#’ + requestData.id + ‘): ‘ + JSON.stringify(requestData)); networkRequest.cancel(); // or .abort() } }; If you use … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)