Skip to content

Instantly share code, notes, and snippets.

@JacobHsu
Created January 7, 2016 05:31
Show Gist options
  • Save JacobHsu/0425b10737a1fe90087f to your computer and use it in GitHub Desktop.
Save JacobHsu/0425b10737a1fe90087f to your computer and use it in GitHub Desktop.
Log into Facebook with phantomJS
var page = require('webpage').create();
page.onConsoleMessage = function(msg) {
console.log(msg);
};
page.open("https://www.facebook.com", function(status) {
if ( status === "success" ) {
page.evaluate(function() {
document.querySelector("input[name='email']").value = "email";
document.querySelector("input[name='pass']").value = "pass";
document.querySelector("#login_form").submit();
console.log("Login submitted!");
});
window.setTimeout(function () {
page.render('./screens/colorwheel.png');
phantom.exit();
}, 5000);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment