Skip to main content

Accurately separate the TLD from the registered domain and subdomains of a URL, using the Public Suffix List. Bydefault, this includes the public ICANN TLDs and theirexceptions. You can optionally support the Public SuffixList'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.0.3.tar.gz (50.6 kB view details)

Uploaded Source

Built Distribution

tldextract-2.0.3-py2.py3-none-any.whl (52.4 kB view details)

Uploaded Python 2Python 3

File details

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

File metadata

  • Download URL: tldextract-2.0.3.tar.gz
  • Upload date:
  • Size: 50.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for tldextract-2.0.3.tar.gz
Algorithm Hash digest
SHA256 3c181659cc8c8945ce5321a35c4159c396fcbb629b619772cb9b12a71dba5f1f
MD5 028176cf2245e4baac0601fe99796906
BLAKE2b-256 32fee6f010a97ea48e802038b083a7316fa28fbaad843eacfbd12637d9d221a2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for tldextract-2.0.3-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 f687c4bbb227af73cd7ead2c0f8f9bacfd4a109a276ae557938df0c04ffd669c
MD5 c9cd66585a3db0a1cf3a32e7f655f40e
BLAKE2b-256 18910a861192d1ff8869bbdd32f88a3190a7c3ad2bea13b2cacfd3d893211bb6

See more details on using hashes here.

Supported by

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