Created
November 12, 2015 16:54
-
-
Save josuebrunel/5214d0b0892aeba2c126 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
{"cookies": [], "address": "https://google.com"} |
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
// 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