Extract domain name with Python

tldextract is the best library to extract the domain name with Python.

Here is how it looks in action:

import tldextract
ext = tldextract.extract('http://forums.bbc.com')
print(ext.registered_domain)

Which would output:

bbc.co.uk

chevron_left
chevron_right

Leave a comment

Your email address will not be published.

Comment
Name
Email
Website