Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import requests, re, robobrowser, sys
- user_email = 'PUT_YOUR_EMAIL_HERE'
- user_password = 'PUT_YOUR_PASSWORD_HERE'
- headers = {'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64; rv:58.0) Gecko/20100101 Firefox/58.0'}
- if user_email == 'PUT_YOUR_EMAIL_HERE' or user_password == 'PUT_YOUR_PASSWORD_HERE':
- print('You need to enter your email and password into the script.')
- sys.exit()
- # Credit to Jon McClung on StackOverflow for the following class
- # https://stackoverflow.com/users/4714742/jon-mcclung
- class Facebook(robobrowser.RoboBrowser):
- url = 'https://facebook.com'
- def __init__(self, email, password):
- self.email = email
- self.password = password
- super().__init__()
- self.login()
- def login(self):
- self.open(self.url)
- login_form = self.get_form(id='login_form')
- login_form['email'] = self.email
- login_form['pass'] = self.password
- self.submit_form(login_form)
- global cookies, html
- cookies = self.session.cookies
- html = self.parsed
- Facebook(user_email, user_password)
- settings_page = requests.get('https://www.facebook.com/settings', headers=headers, cookies=cookies)
- download_link = re.findall(r'<a href="(https://www\.facebook\.com/dyi\S+?)">Download a copy</a> of your Facebook data\.</div>', settings_page.text)[0]
Advertisement
Add Comment
Please, Sign In to add comment