0

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())
ci5c0
  • 1
  • 1

1 Answers1

0

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)
...
Lord Elrond
  • 13,430
  • 7
  • 40
  • 80
  • Traceback (most recent call last): File "fb_email_scraper.py", line 18, in for text in email_scraper: TypeError: 'NoneType' object is not iterable – ci5c0 Oct 28 '19 at 04:43
  • what i did to test this was i first save the page after submitting the profile link and got the page that asks how to reset via email or sms, so after i saved that page i hosted it via apache2 and used the script to scrape the contents wich it worked it printed out the email address but when i enter the profile link when running the script it doesnt print the contents, sorry for not fully understanding how to web scrape been working on this project for a while this is just a sample of the tool – ci5c0 Oct 28 '19 at 04:50
  • so i saved the r.content to a html file and opened it via firefox and theres nothing just the fb reset link and not the following page as expected, what did i do wrong – ci5c0 Oct 28 '19 at 05:00