domain get python code example
Example 1: extract domain name from url python
from urllib.parse import urlparse
domain = urlparse('http://www.example.test/foo/bar').netloc
print(domain) # --> www.example.test
Example 2: python get domain from url
from urllib.parse import urlparse
domain = urlparse('https://supermavster.com').netloc