Created
May 14, 2016 16:28
-
-
Save leemason/d154cfc4153c7aace3635f7f33ba5909 to your computer and use it in GitHub Desktop.
This file contains 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
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