Waiting until page fully loaded before rendering?


#1

I am trying to capture a web page which loads data, and then refreshes itself from 5 day’s data to 1 day’s data automatically.

However, the page.render(output); command is firing on the initial download, and not the “refreshed” version. Here is my script:-

var page = require(‘webpage’).create(),
system = require(‘system’),
address, output;
page.viewportSize = { width: 1024, height: 768 };
address = system.args[1];
output = system.args[2];

page.open(address, function() {
page.render(output);
phantom.exit();
});

Can anyone help me with a solution?

Many thanks
John in Sunny Carnarvon, Western Australia


#2

I found my own solution - use the rasterize.js script and change the TIMEOUT value to suit. IN my case a 5 second TIMEOUT gave the webpage time to reload before the render activated…