Created
July 4, 2014 04:09
-
-
Save siygle/f6cd45b3c4702c5d2500 to your computer and use it in GitHub Desktop.
phantom screenshot
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
var page = require('webpage').create(); | |
var system = require('system'); | |
var address, output, size; | |
if (system.args.length < 3 || system.args.length > 5) { | |
process.exit(1); | |
} else { | |
address = system.args[1]; | |
output = system.args[2]; | |
page.viewportSize = { width: 800, height: 500 }; | |
page.open(address, function(status) { | |
if (status !== 'success') { | |
console.log('cannot load the webpage!'); | |
phantom.exit(); | |
} else { | |
var rect = page.evaluate(function() { | |
return document.querySelector('.panel-container').getBoundingClientRect(); | |
}); | |
page.clipRect = {top: rect.top, left: rect.left, width: rect.width, height: rect.height}; | |
window.setTimeout(function() { | |
page.render(output); | |
phantom.exit(); | |
}, 2000); | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment