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.0.2.tar.gz (102.0 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.0.2-py2.py3-none-any.whl (86.4 kB view details)

Uploaded Python 2Python 3

File details

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

File metadata

  • Download URL: tldextract-3.0.2.tar.gz
  • Upload date:
  • Size: 102.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.9.0

File hashes

Hashes for tldextract-3.0.2.tar.gz
Algorithm Hash digest
SHA256 f188eab8c90ff935f3fa49d9228049cd7f37fb47105c3f15f8e6dd6f6e25924a
MD5 bfeb6f32c6df74cbaa33b1cd522f903f
BLAKE2b-256 a98d926e3dc9e2b4111e33964b63f603b41c86c6033b92347f817448f731db8d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: tldextract-3.0.2-py2.py3-none-any.whl
  • Upload date:
  • Size: 86.4 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.9.0

File hashes

Hashes for tldextract-3.0.2-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 d2762b1aa2a36857df8420d63c2c31706e4924da8773439a543365d38459afd8
MD5 5c7bcb0d452fba7d35eddeaf709887d6
BLAKE2b-256 ff9e578ea24d0149a5c179ded8ea53e2b8fc35d22f7bfdee9564844873b147ea

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