Sitemap

Extract email address from webpage with python.

Jan 5, 2023
import requests
import re
from bs4 import BeautifulSoup
import os
import platform

def clear():
if platform.system()=="Windows":
os.system("cls")
else:
os.system("clear")
clear()

def crawl_webpage(url):
# Send a GET request to the webpage
response = requests.get(url)
html_content = response.text

# Parse the HTML content
soup = BeautifulSoup(html_content, 'html.parser')

# Find all the email addresses on the webpage
email_pattern = r'[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+'
emails = re.findall(email_pattern, html_content)

# Print the email addresses
for email in emails:
print(email)

# Get the URL from the user
url = input('Enter the URL: ')

# Crawl the webpage
crawl_webpage(url)

--

--