Skip to content

Instantly share code, notes, and snippets.

@JacobDorman
Created September 29, 2015 09:15
Show Gist options
  • Save JacobDorman/a0c7e6d468f7794b3ce1 to your computer and use it in GitHub Desktop.
Save JacobDorman/a0c7e6d468f7794b3ce1 to your computer and use it in GitHub Desktop.
var page = require('webpage').create(),
system = require('system');
page.viewportSize = {width: 1280, height: 1024};
if (system.args.length === 1) {
console.log('Usage: scrollCapture.js <some URL>');
phantom.exit();
}
var url = system.args[1];
var filename = url.replace(/(https|http):\/\//gi, '')
.replace(/[^a-z0-9]/gi, '_').toLowerCase();
page.open(url, function (status) {
if (status !== 'success') {
console.log('Unable to load the address!');
phantom.exit();
} else {
var capname1 = filename + '--1.jpg';
page.render(capname1);
console.log(capname1);
window.setTimeout(function () {
page.scrollPosition = {top: 512, left: 0};
window.setTimeout(function () {
var capname2 = filename + '--2.jpg';
page.render(capname2);
console.log(capname2);
phantom.exit();
}, 500);
}, 500);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment