Skip to content

Instantly share code, notes, and snippets.

@davebarnwell
Created January 31, 2016 11:20
Show Gist options
  • Select an option

  • Save davebarnwell/af6749a368ea853f9a8e to your computer and use it in GitHub Desktop.

Select an option

Save davebarnwell/af6749a368ea853f9a8e to your computer and use it in GitHub Desktop.
Screen capture a webpage with phantomjs
//
// Screen shot a webpage using phantomjs
//
// phantomjs capture.js url filename.png
//
var page = require('webpage').create(),
system = require('system'),
url, img_filename_output;
if (system.args.length < 3) {
console.log('Usage: capture.js URL filename');
phantom.exit(1);
} else {
url = system.args[1];
img_filename_output = system.args[2];
page.open(url, function() {
page.render(img_filename_output);
phantom.exit();
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment