Skip to content

Instantly share code, notes, and snippets.

@siygle
Created July 4, 2014 04:09
Show Gist options
  • Save siygle/f6cd45b3c4702c5d2500 to your computer and use it in GitHub Desktop.
Save siygle/f6cd45b3c4702c5d2500 to your computer and use it in GitHub Desktop.
phantom screenshot
var page = require('webpage').create();
var system = require('system');
var address, output, size;
if (system.args.length < 3 || system.args.length > 5) {
process.exit(1);
} else {
address = system.args[1];
output = system.args[2];
page.viewportSize = { width: 800, height: 500 };
page.open(address, function(status) {
if (status !== 'success') {
console.log('cannot load the webpage!');
phantom.exit();
} else {
var rect = page.evaluate(function() {
return document.querySelector('.panel-container').getBoundingClientRect();
});
page.clipRect = {top: rect.top, left: rect.left, width: rect.width, height: rect.height};
window.setTimeout(function() {
page.render(output);
phantom.exit();
}, 2000);
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment