Skip to content

Instantly share code, notes, and snippets.

@quanon
Created September 27, 2016 23:24
Show Gist options
  • Save quanon/95e71c6a296e274d1760c8c8cd706bf1 to your computer and use it in GitHub Desktop.
Save quanon/95e71c6a296e274d1760c8c8cd706bf1 to your computer and use it in GitHub Desktop.
var page = require('webpage').create();
var args = require('system').args;
page.viewportSize = {
width: 1200,
height: 780
};
page.open(args[1], function (status) {
if (status !== 'success') {
console.log('Unable to load the address!');
} else {
var clipRect = page.evaluate(function () {
return document.querySelector('body').getBoundingClientRect();
});
page.clipRect = {
top: clipRect.top,
left: clipRect.left,
width: clipRect.width,
height: clipRect.height
};
window.setTimeout(function () {
page.render('capture.png');
phantom.exit();
}, 5000);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment