Last active
November 18, 2015 17:54
-
-
Save josuebrunel/b9ecc94289a110c239a7 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
{ | |
"url": "http://idp.debian.local/login/", | |
"page": "http://idp.debian.local/manage/users/", | |
"username_id": "#id_username", | |
"username_value": "root", | |
"password_id": "#id_password", | |
"password_value": "root" | |
} |
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 system = require('system'); | |
var page = require('webpage').create(); | |
function json_dump(data){ | |
console.log(JSON.stringify(data)); | |
} | |
input = JSON.parse(system.stdin.read(2000)); | |
page.open(input.url, function(status){ | |
if (status !== 'success'){ | |
console.log(JSON.stringify({'result':status})); | |
phantom.exit(1); | |
} | |
page.injectJs('jquery.min.js'); | |
page.onLoadFinished = function(){ | |
page.render('login.png'); | |
console.log(JSON.stringify({'result': status, 'cookies': page.cookies})); | |
phantom.exit(0); | |
} | |
page.evaluate(function(input ){ | |
if ($(input.username_id).length == 0){ | |
console.log(JSON.stringify({'result': 'ok'})); | |
} | |
$(input.username_id).val(input.username_value); | |
$(input.password_id).val(input.password_value); | |
$(input.username_id).parents('form').find('input[type=submit]').click(); | |
}, input); | |
}); |
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 system = require('system'); | |
var page = require('webpage').create(); | |
function json_dump(data){ | |
console.log(JSON.stringify(data)); | |
} | |
input = JSON.parse(system.stdin.read(2000)); | |
page.open(input.page, function(status){ | |
if (status !== 'success'){ | |
console.log(JSON.stringify({'result':status})); | |
phantom.exit(1); | |
} | |
page.render('page.png'); | |
console.log(JSON.stringify({'result':'ok', 'cookies': page.cookies, 'content': page.content})); | |
phantom.exit(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment