Instantly share code, notes, and snippets.

Embed
What would you like to do?
#!/bin/bash
> /tmp/cookies.txt
/usr/local/bin/phantomjs --cookies-file="/tmp/cookies.txt" --ssl-protocol=any --ignore-ssl-errors=true /usr/local/bin/screenshot.js $1
var page = require('webpage').create(),
system = require('system'),
address = system.args[1];
page.viewportSize = page.clipRect = {
width: 1280,
height: 960
};
page.onError = page.onConsoleMessage = function() {};
page.customHeaders = {
"Referer": address
};
page.onLoadStarted = function() {
window.setTimeout(function() {
phantom.exit(1);
}, 10000);
};
page.open(address, function(status) {
page.evaluate(function() {
document.body.bgColor = 'white';
});
if (status == 'success') {
window.setTimeout(function() {
page.render('/dev/stdout');
phantom.exit(0);
}, 300);
} else {
console.log('Page.open returned ' + page.reason);
phantom.exit(1);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment