Skip to main content

Accurately separates a URL's subdomain, domain, and public suffix, using the Public Suffix List (PSL). 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 a URL's subdomain, domain, and public suffix, using the Public Suffix List (PSL).

>>> 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.4.2.tar.gz (105.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.4.2-py3-none-any.whl (93.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: tldextract-3.4.2.tar.gz
  • Upload date:
  • Size: 105.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.2

File hashes

Hashes for tldextract-3.4.2.tar.gz
Algorithm Hash digest
SHA256 98e36b0aa3a6d8fd084d80d75ae1372da02027efb556c146a59dfd14457071ba
MD5 c8eb5a85786dace40a42a0c74dfc4d22
BLAKE2b-256 bfd7f146b8ff570f138f98521dd770026f790b43448aa10d19706bc1d09a44a8

See more details on using hashes here.

File details

Details for the file tldextract-3.4.2-py3-none-any.whl.

File metadata

  • Download URL: tldextract-3.4.2-py3-none-any.whl
  • Upload date:
  • Size: 93.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.2

File hashes

Hashes for tldextract-3.4.2-py3-none-any.whl
Algorithm Hash digest
SHA256 1f168f0a1c000a757aefed94a5bda10349c58976cb2ef1cc17c6e3b213440521
MD5 e8c9e5bf9224fed98bf3f60cc274f3e2
BLAKE2b-256 a613bd0d0d855df1c161bdf4098b7006d9f8e68a5288377da12adfb801ddcb1d

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