Skip to content

Instantly share code, notes, and snippets.

@kasparsd
Created January 23, 2018 20:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kasparsd/3985e31829e08b823c6b6a6f35ae09ee to your computer and use it in GitHub Desktop.
Save kasparsd/3985e31829e08b823c6b6a6f35ae09ee to your computer and use it in GitHub Desktop.
#!/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