Skip to content

Instantly share code, notes, and snippets.

@TunedMystic
Last active October 4, 2022 00:16
Show Gist options
  • Save TunedMystic/eeb95a23a2601890fe4f17b33f53ed7a to your computer and use it in GitHub Desktop.
Save TunedMystic/eeb95a23a2601890fe4f17b33f53ed7a to your computer and use it in GitHub Desktop.
Parse the domain name from a url.
from urllib.parse import urlparse
def parse_domain_name(url: str) -> str:
"""
Parse the domain name from the given url.
"""
return urlparse(url).hostname.split('.')[-2]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment