

0 / 2 embers
0 / 3000 xp
click for more info
Complete a lesson to start your streak
click for more info
Still calibrating
click for more info
Not enough gems
Cost: 6 gems
1: Web Addresses
incomplete
2: Web Addresses Quiz
incomplete
3: DNS
incomplete
4: What Is the Domain Name System?
incomplete
5: Subdomains
incomplete
This lesson's interactive features are locked, please to keep using them
A "domain name" or "hostname" is just one portion of a URL. We'll get to the other parts of a URL later.
For example, the URL https://homestarrunner.com/toons has a hostname of homestarrunner.com. The https:// and /toons portions aren't part of the domain name -> IP address mapping that we've been talking about.
Python provides the urlparse function from the urllib.parse module that helps parse URLs into their components:
from urllib.parse import urlparse
parsed_url = urlparse("https://homestarrunner.com/toons")
And then you can extract just the hostname using the hostname attribute:
hostname = parsed_url.hostname
print(hostname) # homestarrunner.com
Complete the get_domain_name_from_url function. Given a full URL, it should return the domain (or host) name.