Created
June 28, 2016 12:16
-
-
Save ygerasimov/782c8608d7e3e7653c1227b3c6b692da 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(), | |
address, output, size; | |
if (phantom.args.length < 4 || phantom.args.length > 5) { | |
console.log('Usage: viewport.js URL filename sizeX sizeY'); | |
phantom.exit(); | |
} else { | |
address = phantom.args[0]; | |
output = phantom.args[1]; | |
sizeX = phantom.args[2]; | |
sizeY = phantom.args[3]; | |
page.viewportSize = { width: sizeX, height: sizeY }; | |
page.open(address, function (status) { | |
if (status !== 'success') { | |
console.log('Unable to load the address!'); | |
} else { | |
window.setTimeout(function () { | |
page.render(output); | |
phantom.exit(); | |
}, 200); | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment