Skip to content

Instantly share code, notes, and snippets.

@josuebrunel
Last active November 18, 2015 17:54
Show Gist options
  • Save josuebrunel/b9ecc94289a110c239a7 to your computer and use it in GitHub Desktop.
Save josuebrunel/b9ecc94289a110c239a7 to your computer and use it in GitHub Desktop.
{
"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"
}
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);
});
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