March 2019
Beginner
490 pages
12h 40m
English
We can use regex package to identify common patterns such as emails and URLs. With BeautifulSoup, you can specify regular expression patterns to match specific tags. In this script, we are extracting email addresses that match a specific pattern.
You can find the following code in the extract_emails_from_url.py file inside the beautifulSoup folder:
import requestsimport refrom bs4 import BeautifulSoupurl = input("Enter the URL: ")response = requests.get(url)html_page = response.textemail_pattern=re.compile(r'\b[\w.-]+?@\w+?\.\w+?\b')for match in re.findall(email_pattern,html_page): print(match)
Read now
Unlock full access