submit post via python and scraping via bs4

503 Views Asked by At

Im trying to make a tool that scrapes the resulting page of facebooks password reset link and have the script print out the email, but my problem is its not submitting the payload not sure what im doing wrong but any help will be appreciated, im new to scraping and was trying to make the script work with the least amount of lines till i get better at it...

in short trying to submit the post and scrape the email of the following page...

from bs4 import BeautifulSoup
import requests

url = "https://www.facebook.com/login/identify/"
target_profile = raw_input("Enter the Target's Profile Link: ")
payload = {"email": target_profile, "submit": "submit"}
r = requests.post(url, data=payload)

html_soup = BeautifulSoup(r.content, 'html.parser')
type(html_soup)
#info_container = html_soup.find_all('div', class_= 'uiInputLabel clearfix uiInputLabelLegacy')
#print(type(info_container))
#print(len(info_container))

email_scraper = html_soup.find('div', class_= '_8u _42ef')

for text in email_scraper:
        print(text.prettify())
1

There are 1 best solutions below

3
Lord Elrond On

You forgot to serialize your payload with json.dumps:

import json

payload = json.dumps({"email": target_profile, "submit": "submit"})
r = requests.post(url, data=payload)
...