Today we are going out to find the domain name out of the URL string through Python. There is a similar Kata in Codewars to extract the domain name from a URL through Python.
Let’s say we have the URL string which is https://hecodesit.com/ What would be the domain name of this URL? The domain name will be hecodesit.
The URL string has 4 main parts.
The first Part is Protocol, a Protocol is rules to transfer data. The most common protocols used in today’s era are HTTPs and HTTP. To know about the difference between HTTP and HTTPs visit HERE.
The Second Part is Subdomain, it is actually a part of the domain. For e.g, my site offers things to sell and I want a shop for my site, in order to do so, I create a subdomain with the same domain name https://shop.hecodesit.com where the shop is a subdomain. To know more about the Subdomain visit HERE.
The Third Part is the Domain Name, It is also known as Root Domain. The domain name is the identification of your site. It is always unique, two people can’t have the same Domain name. To know more about it visit HERE
The Fourth Part is the Top Level Domain, It often describes the purpose of the website. For e.g, if the Top-level Domain is .org we identify the site as an Organization site if a site ends with .com we identify it as a commercial site, etc. To know more about the Top Level Domains visit HERE
Find the Code at https://hecodesit.com/python-get-domain-name-from-url-python-solutions/
For further actions, you may consider blocking this person and/or reporting abuse
Top comments (0)