Created
May 16, 2023 09:20
-
-
Save swdevbali/aa2e099d53f3b46ab5f535cbd7052b72 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# regex_soup.py | |
import re | |
from urllib.request import urlopen | |
url = "http://olympus.realpython.org/profiles/dionysus" | |
page = urlopen(url) | |
html = page.read().decode("utf-8") | |
pattern = "<title.*?>.*?</title.*?>" | |
match_results = re.search(pattern, html, re.IGNORECASE) | |
title = match_results.group() | |
title = re.sub("<.*?>", "", title) # Remove HTML tags | |
print(title) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment