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.3.1.tar.gz (110.8 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.3.1-py3-none-any.whl (93.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: tldextract-3.3.1.tar.gz
  • Upload date:
  • Size: 110.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.5

File hashes

Hashes for tldextract-3.3.1.tar.gz
Algorithm Hash digest
SHA256 fe15ac3205e5a25b61689369f98cb45c7778a8f2af113d7c11559ece5195f2d6
MD5 855b60099fdc4b59080dff55690fef7d
BLAKE2b-256 80d875264c54cfa1371d2a42fb613c24d71628c411764ab0d5046b54ca18a5b2

See more details on using hashes here.

File details

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

File metadata

  • Download URL: tldextract-3.3.1-py3-none-any.whl
  • Upload date:
  • Size: 93.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.5

File hashes

Hashes for tldextract-3.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 35a0260570e214d8d3cfeeb403992fe9e2b686925f63c9b03c5933408ac2aa5a
MD5 e0a143329ff68faf060a043d29db1b1e
BLAKE2b-256 190118ef86a1c7dc1050ebda6f325363b1a052d91494aef0c3914b13445826a8

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