tldextract accurately separates the gTLD or ccTLD (generic or country code top-level domain) from the registered domain and subdomains of a URL.
>>> import tldextract
>>> tldextract.extract('http://forums.news.cnn.com/')
ExtractResult(subdomain='forums.news', domain='cnn', suffix='com')
>>> tldextract.extract('http://forums.bbc.co.uk/') # United Kingdom
ExtractResult(subdomain='forums', domain='bbc', suffix='co.uk')
>>> tldextract.extract('http://www.worldbank.org.kg/') # Kyrgyzstan
ExtractResult(subdomain='www', domain='worldbank', suffix='org.kg')
ExtractResult is a namedtuple, so it’s simple to access the parts you want.
>>> ext = tldextract.extract('http://forums.bbc.co.uk')
>>> (ext.subdomain, ext.domain, ext.suffix)
('forums', 'bbc', 'co.uk')
>>> # rejoin subdomain and domain
>>> '.'.join(ext[:2])
'forums.bbc'
>>> # a common alias
>>> ext.registered_domain
'bbc.co.uk'
By default, this package supports the public ICANN TLDs and their exceptions. You can optionally support the Public Suffix List’s private domains as well.
Release files for tldextract 2.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| tldextract-2.1.0.tar.gz | 51.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| tldextract-2.1.0-py2.py3-none-any.whl | Python 3, Python 2 | none | any | Details |
Total release size:103.7 kB
Release files / tldextract-2.1.0.tar.gz
| Download URL | tldextract-2.1.0.tar.gz |
|---|---|
| Size | 51.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
796d86aa22c382770b28db45547b298cbf855dcdcd8e1c7264419d96c0f2381a
|
|
BLAKE2b-256 checksum How to use checksums |
158c6c852f0dd1cc6ddd43d4eb8b67b78a099d6b8e25d6144f85bdfb08df9645
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / tldextract-2.1.0-py2.py3-none-any.whl
| Download URL | tldextract-2.1.0-py2.py3-none-any.whl |
|---|---|
| Size | 52.6 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
6a705710f3a1d5ce8a084c888db7bad7aff1dcdf27962f7c7f7058cc42349212
|
|
BLAKE2b-256 checksum How to use checksums |
395e57290fb1322b5ca14983216ae78ad3ae1c2dd4dc7182e6a88e0c3491e4a6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |