Created
March 2, 2016 18:16
-
-
Save manu-chroma/8c5b39bef7335fa23a6f to your computer and use it in GitHub Desktop.
using robobrowser and beautiful soup. Supports both python 2.7 and 3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from robobrowser import RoboBrowser | |
from getpass import getpass | |
from bs4 import BeautifulSoup as bs | |
browser = RoboBrowser(history=True) | |
browser.open('https://m.facebook.com/') | |
# GETTING INPUT | |
mail = input('Email : ') | |
password = getpass('Password : ') | |
#FORM FILL | |
form = browser.get_form() | |
form['email'].value=mail | |
form['pass'].value=password | |
browser.submit_form(form) | |
#PARSER (can also be implemented from robobrowser) | |
soup = browser.parsed | |
try: | |
soup = soup.find("label", {"for" : "u_0_0"}) | |
username = soup.a | |
username.clear() | |
username = str(username) | |
profile = username[username.find('/')+1 : username.find('?')] | |
print (profile) | |
except: | |
print("wrong credentials!") | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment