Skip to content

Instantly share code, notes, and snippets.

@leemason
Created May 14, 2016 16:28
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save leemason/d154cfc4153c7aace3635f7f33ba5909 to your computer and use it in GitHub Desktop.
Save leemason/d154cfc4153c7aace3635f7f33ba5909 to your computer and use it in GitHub Desktop.
var page = require('webpage').create(),
system = require('system'),
loc, address;
if (system.args.length < 3) {
console.log('Usage: screenshot.js <some URL> <some LOCATION>');
phantom.exit();
}
//viewportSize being the actual size of the headless browser
page.viewportSize = { width: 1024, height: 768 };
//the clipRect is the portion of the page you are taking a screenshot of
page.clipRect = { top: 0, left: 0, width: 1024, height: 768 };
address = system.args[1];
loc = system.args[2];
page.open(address, function(status) {
if (status !== 'success') {
console.log('FAIL to load the address');
} else {
//save to location
page.render(loc);
}
phantom.exit();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment