Skip to content

Instantly share code, notes, and snippets.

@hagino3000
Last active January 21, 2020 22:21
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hagino3000/5762896 to your computer and use it in GitHub Desktop.
Save hagino3000/5762896 to your computer and use it in GitHub Desktop.
Capture screenshot using phantom.js
var page = new WebPage(),
address, output, size;
if (phantom.args.length != 2) {
console.log('Give me URL and filename');
phantom.exit();
} else {
address = phantom.args[0];
output = phantom.args[1];
page.viewportSize = { width: 1024, height: 768 };
page.open(address, function (status) {
if (status !== 'success') {
console.log('Unable to load the address!');
} else {
setTimeout(function() {
page.render(output);
phantom.exit();
}, 1000);
}
});
}
phantomjs capture.js http://www.yahoo.co.jp yahoo.png
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment