Skip to content

Instantly share code, notes, and snippets.

@josuebrunel
Created November 12, 2015 16:54
Show Gist options
  • Save josuebrunel/5214d0b0892aeba2c126 to your computer and use it in GitHub Desktop.
Save josuebrunel/5214d0b0892aeba2c126 to your computer and use it in GitHub Desktop.
{"cookies": [], "address": "https://google.com"}
// phantomjs --debug=true --ignore-ssl-errors=yes --ssl-protocol=any test.js < data.json
var page = require('webpage').create();
var system = require('system');
var input = JSON.parse(system.stdin.read(2000));
console.log(JSON.stringify(input));
//phantom.onConsoleMessage = function(msg){ console.log(msg); }
page.onResourceError = function(resourceError) {
page.reason = resourceError.errorString;
page.reason_url = resourceError.url;
};
page.open(input.address, function(status){
if (status !== 'success'){
console.log("url: "+page.reason_url+"reason: "+page.reason);
phantom.exit(1)
}
page.onLoadFinished = function(){
input.cookies = page.cookies;
console.log(JSON.stringify(input));
phantom.exit();
};
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment