I've created a script to scrape name
and email
address from a webpage. When I run my script I get the name
accordingly but in case of email
this is what I get aeccdcd7cfc0eedadcc783cdc1dc80cdc1c3
. The string that I get instead of email
changes every time I run the script.
I've tried so far:
import requests
from bs4 import BeautifulSoup
url = "https://www.seafoodsource.com/supplier-directory/Tri-Cor-Flexible-Packaging-Inc"
res = requests.get(url,headers={"User-Agent":"Mozilla/5.0"})
soup = BeautifulSoup(res.text,'lxml')
name = soup.select_one("[class$='-supplier-view-main-container'] > h1").text
email = soup.select_one("[class='__cf_email__']").get("data-cfemail")
print(f'{"Name: "}{name}\n{"Email: "}{email}')
Current output:
Name: Tri-Cor Flexible Packaging Inc
Email: aeccdcd7cfc0eedadcc783cdc1dc80cdc1c3
Expected output:
Name: Tri-Cor Flexible Packaging Inc
Email: bryan@tri-cor.com
PS I'm not after any solution related to any browser simulator, as in selenium.
How can I get that email from that page using requests?
from Can't get a certain item from a webpage using requests
No comments:
Post a Comment