Skip to content Skip to sidebar Skip to footer

Python3 How Would I Log In Facebook Using Requests

is the email box

Solution 1:

You always need to pay attention to any additional (hidden) fields, that are sent along credentials, and might be needed for any server processing.

That is the case for your example with runescape.com. When you use your browser to intercept data, that is normally being sent along with the form, you can modify the script in this manner:

import requests
from bs4 import BeautifulSoup

body = {'username':'xxxx@hotmail.com','password':'xxxxx','submit':'Login','mod':'www','dest':'community'}
con = requests.post('https://secure.runescape.com/m=weblogin/login.ws', data=body)
s = BeautifulSoup(con.content)
print(s)

You can see mod and dest parameters were needed to make the server processing function. As for the submit button, it is rarely checked for, but it is always safer to include it as well (as I did in this example).

The result is not 404 anymore, but the login will nevertheless fail, as there is Captcha in place to prevent automatic login.

As for Facebook, there are a lot of complicated supplementary fields, that would require a lot of reverse engineering to be done. I would strongly suggest to consider using the official Facebook Graph API (https://developers.facebook.com/docs/graph-api) if possible to accomplish what you need.

Post a Comment for "Python3 How Would I Log In Facebook Using Requests"