Skip to content

Instantly share code, notes, and snippets.

@bitfed

bitfed/index.js Secret

Created June 26, 2016 09:11
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 bitfed/5e6e7b3a0d4ea1df441f1bbfc7a42435 to your computer and use it in GitHub Desktop.
Save bitfed/5e6e7b3a0d4ea1df441f1bbfc7a42435 to your computer and use it in GitHub Desktop.
Logging in
'use strict';
var phantom = require("phantom");
var _ph, _page, _outObj;
phantom.create().then(ph => {
_ph = ph;
return _ph.createPage();
}).then(page => {
_page = page;
_page.on('onConsoleMessage', msg => {
console.log(msg);
});
return _page.open('https://url.with.login/form');
}).then(status => {
console.log(status);
_page.evaluate(function () {
console.log('beginning eval');
document.getElementById('cbStaff').click();
document.getElementById('txtLoginUsername').value = 'email@gmail.com';
document.getElementById('txtLoginPassword').value = 'password';
document.getElementById('btnLogin').click();
//Not sure how to handle being logged in and forwarded
});
}).then(content => {
_page.close();
_ph.exit();
}).catch(error => {
console.log(error);
_ph.exit();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment