fb_pixel

Get domain name from URL

Development | Programming languages
Description
How to get a domain name from a URL?
Attachments
No attachments
Info
Description
from urllib.parse import urlparse

parsed_uri = urlparse('https://www.engprod-charter.net') result_scheme = '{uri.scheme}'.format(uri=parsed_uri) result_netloc = '{uri.netloc}'.format(uri=parsed_uri)
print(result_scheme) print(result_netloc)


or

from urllib.parse import urlsplit

url = "https://www.engprod-charter.net/get-domain-name-from-url/" base_url = "{0.scheme}://{0.netloc}/".format(urlsplit(url))
print(url) print(base_url)



on November 05th, 2019 (9:57 pm)
All coments
It works great, try..
on November 13th, 2019 (8:51 pm)