scrape email in a list from website python 1

scrape email in a list from website python

#email regex found on stackoverflow
email_regex= "([a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+)"
#to put all mails in a list from a string that refers to an html text code 
import re
import request
url = requests.get("PUT URL HERE")
html_text = url.text
emails = re.findall(email_regex, html_text)

Here is what the above code is Doing:
1. We import the re module, which contains the regular expression functions.
2. We import the requests module, which allows us to make HTTP requests.
3. We make a GET request to the URL we want to scrape.
4. We store the HTML text of the page in a variable.
5. We use the re.findall() function to find all the email addresses in the HTML text.
6. We print the list of email addresses.

Similar Posts