scrape email from website python code example
Example 1: scrape email in a list from website python
email_regex= "([a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+)"
import re
import request
url = requests.get("PUT URL HERE")
html_text = url.text
emails = re.findall(email_regex, html_text)
Example 2: How to scrape email addresses from a website using Python
from extract_emails import EmailExtractor
from extract_emails.browsers import BrowserInterface
from selenium import webdriver
from selenium.webdriver.firefox.options import Options
class FirefoxBrowser(BrowserInterface):
def __init__(self):
ff_options = Options()
self._driver = webdriver.Firefox(
options=ff_options, executable_path="/home/di/geckodriver",
)
def close(self):
self._driver.quit()
def get_page_source(self, url: str) -> str:
self._driver.get(url)
return self._driver.page_source
with FirefoxBrowser() as browser:
email_extractor = EmailExtractor("http://www.tomatinos.com/", browser, depth=2)
emails = email_extractor.get_emails()
for email in emails:
print(email)
print(email.as_dict())