Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import re
- import requests
- from pyquery import PyQuery as pq
- def main(username, password):
- session = requests.session()
- dtsg = login(session, username, password)
- def login(session, username, password):
- '''
- Login to Facebook
- '''
- # Navigate to the Facebook homepage
- response = session.get('https://facebook.com')
- # Construct the DOM
- dom = pq(response.text)
- # Get the lsd value from the HTML. This is required to make the login request
- lsd = dom('[name="lsd"]').val()
- # Perform the login request
- response = session.post('https://www.facebook.com/login.php?login_attempt=1', data={
- 'lsd': lsd,
- 'email': username,
- 'pass': password,
- 'default_persistent': '0',
- 'timezone': '-60',
- 'lgndim': '',
- 'lgnrnd': '',
- 'lgnjs': '',
- 'locale': 'en_GB',
- 'qsstamp': ''
- })
- dom1 = pq(response.text)
- #print(dom1)
- try:
- #dtsg = re.search('_4rbf _53ij', response.content)
- print(response.content)
- except KeyError:
- raise Exception('Login Failed!')
- #print(dtsg)
- #return dtsg
- try:
- main(username='', password='')
- except Exception as e:
- print(e)
- #it's important to mention that the Code was written by someone else, i changed it a little bit.
Add Comment
Please, Sign In to add comment