Skip to main content

Accurately separate the TLD from the registered domain and subdomains of a URL, using the Public Suffix List. By default, this includes the public ICANN TLDs and their exceptions. You can optionally support the Public Suffix List's private domains as well.

Project description

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tldextract-2.2.1.tar.gz (54.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tldextract-2.2.1-py2.py3-none-any.whl (48.7 kB view details)

Uploaded Python 2Python 3

File details

Details for the file tldextract-2.2.1.tar.gz.

File metadata

  • Download URL: tldextract-2.2.1.tar.gz
  • Upload date:
  • Size: 54.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.18.4 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/2.7.12

File hashes

Hashes for tldextract-2.2.1.tar.gz
Algorithm Hash digest
SHA256 b72bef6013de67c7fa181250bc2c2e089a994d259c09ca95a9771f2f97e29ed1
MD5 a68e8c20c0189200cf118e5ea85d2292
BLAKE2b-256 3581ec1f53b7113d3ea340019d184fa0be2cdf8b195cd66d9b96811af65500fd

See more details on using hashes here.

File details

Details for the file tldextract-2.2.1-py2.py3-none-any.whl.

File metadata

  • Download URL: tldextract-2.2.1-py2.py3-none-any.whl
  • Upload date:
  • Size: 48.7 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.18.4 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/2.7.12

File hashes

Hashes for tldextract-2.2.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 2c1c5d9d454f79734b4f3da0d603856dd9f820753410a3e9abf0a0c9fde33e97
MD5 48ae2c50fb4379e498e08dd1f5f8224a
BLAKE2b-256 1e9018ac0e5340b6228c25cc8e79835c3811e7553b2b9ae87296dfeb62b7866d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page