Skip to content

Instantly share code, notes, and snippets.

@PirosB3
Created July 21, 2013 08:03
Show Gist options
  • Save PirosB3/6047877 to your computer and use it in GitHub Desktop.
Save PirosB3/6047877 to your computer and use it in GitHub Desktop.
page = require('webpage').create(),
system = require('system');
var address = 'http://localhost/';
var output = '/tmp/screen.png';
page.clipRect = { top: 0, left: 0, width: 1280, height: 720 };
page.open(address, function (status) {
if (status !== 'success') {
console.log('Unable to load the address!');
phantom.exit();
} else {
window.setTimeout(function () {
page.render(output);
phantom.exit();
}, 200);
}
});
@liluxdev
Copy link

In realtà il setTimeout dovrebbe risolvere un bug di render che usa un altro thread e non è completamente sincrona quindi andrebbe solo prima della exit()

Vedi: http://stackoverflow.com/questions/15205538/where-are-screenshots-from-phantom-js-saved

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment