Created
October 26, 2021 04:08
-
-
Save bitcoinmeetups/ab2dd4e55df9556f4622e8fcdefae16a to your computer and use it in GitHub Desktop.
Revisions
-
bitcoinmeetups created this gist
Oct 26, 2021 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,38 @@ """ Use BeautifulSoup to log into Facebook from the Terminal """ import requests from bs4 import BeautifulSoup url = 'https://www.facebook.com/login.php' # Get the login page r = requests.get(url) # Parse the HTML soup = BeautifulSoup(r.text, 'html.parser') # Find the login form form = soup.find('form', {'id': 'login_form'}) # Get the form action form_action = form.get('action') # Get the form fields form_fields = {} for field in form.find_all('input'): form_fields[field.get('name')] = field.get('value') # Set the email and password form_fields['email'] = '<your email>' form_fields['pass'] = '<your password>' # Post the form r = requests.post(form_action, data=form_fields) # Get the home page r = requests.get('https://www.facebook.com/') # Print the home page print(r.text)