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-3.1.1.tar.gz (103.2 kB view details)

Uploaded Source

Built Distribution

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

tldextract-3.1.1-py2.py3-none-any.whl (87.1 kB view details)

Uploaded Python 2Python 3

File details

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

File metadata

  • Download URL: tldextract-3.1.1.tar.gz
  • Upload date:
  • Size: 103.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.7.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.5

File hashes

Hashes for tldextract-3.1.1.tar.gz
Algorithm Hash digest
SHA256 1d5883c496da3a8aa71d1f4da4862ce374dc7ccf45e4bb67deb2016ec34f8d33
MD5 e14e36f923cb2c19174438f39f1e3c8a
BLAKE2b-256 ed8e719a8f4c5450c49450dd771d527e198238e1dd26c28b955ec438b16f3c26

See more details on using hashes here.

File details

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

File metadata

  • Download URL: tldextract-3.1.1-py2.py3-none-any.whl
  • Upload date:
  • Size: 87.1 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.7.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.5

File hashes

Hashes for tldextract-3.1.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 3b73d762ad08b5eee8ae4a01fb66990f1aa654f64e40035d57134005385f0b3d
MD5 fd17e34d2b1a527bbff760ba1bfe2a07
BLAKE2b-256 3358954c88deea3964e4e76c48c158f09773c6a879f58d2588352d0949a2912e

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