Created
January 31, 2016 11:20
-
-
Save davebarnwell/af6749a368ea853f9a8e to your computer and use it in GitHub Desktop.
Screen capture a webpage with phantomjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // | |
| // 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