Skip to content

Instantly share code, notes, and snippets.

@ecin
Created April 23, 2012 21:06
Show Gist options
  • Select an option

  • Save ecin/2473860 to your computer and use it in GitHub Desktop.

Select an option

Save ecin/2473860 to your computer and use it in GitHub Desktop.
Log into Facebook with phantomJS
console.log("got here");
var page = require('webpage').create();
page.onConsoleMessage = function(msg) {
console.log(msg);
};
page.open("http://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('colorwheel.png');
phantom.exit();
}, 5000);
}
});
@swapnilkadam92

Copy link
Copy Markdown

It's not working. It's not working. It's not working. It's not working. It's not working. It's not working. It's not working. It's not working. It's not working. It's not working. It's not working. It's not working. It's not working.

@steezeburger

Copy link
Copy Markdown

^ Are you kidding me dude?

@DarckBlezzer

DarckBlezzer commented Aug 18, 2016

Copy link
Copy Markdown

For all those who can't login, or don't get any of content,
use this command phantomjs --ssl-protocol=any myscript

@grit0

grit0 commented Sep 5, 2016

Copy link
Copy Markdown

edit "u_0_1" to "loginbutton"

@staplesj

staplesj commented Apr 5, 2017

Copy link
Copy Markdown

Worked fine for me, but no pictures showed. Is there a way of grabbing the pictures too using PhantomJS?

@patrioticcow

Copy link
Copy Markdown
document.querySelector("input[name='email']").value = "email";
document.querySelector("input[name='pass']").value = "pass";
document.getElementById("u_0_1").click();

@Shayan20

Copy link
Copy Markdown

type error araha hai null is not an object

@marcioadr88

Copy link
Copy Markdown

It gives me this screenshot, any ideas?
colorwheel

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment