I need a string method to isolate the top-level domain of a URL in Python. For example, consider the URL
"https://stackoverflow.com/questions/ask"
I want to extract just the ".com" without anything after or before that.
I tried something naiive:
domain = URL.split(".")
Use the standard library's URL parser (
urllib.parse) to extract the host name, then split on.to retrieve the TLD: