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.

It does this via 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.3.tar.gz (105.6 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.3-py3-none-any.whl (93.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: tldextract-3.4.3.tar.gz
  • Upload date:
  • Size: 105.6 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.3.tar.gz
Algorithm Hash digest
SHA256 d3fbbfcdadbaff5d414dd8a77cfcc8c3aa811fa5470d8bad289b4c508f39d778
MD5 67c73de8a8ba2eebd98f25b707e58a3b
BLAKE2b-256 f6c631e43b2ba3c21421c0d3beb5c6a616d649fcb008054c770b594dcd7c7805

See more details on using hashes here.

File details

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

File metadata

  • Download URL: tldextract-3.4.3-py3-none-any.whl
  • Upload date:
  • Size: 93.3 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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 5ed3fd01df4e78b8b378bdff94397cd8cdb130b54d2681c40d254beadd50f69f
MD5 4b24f8c56e12bf1ba9499dfcff9374f7
BLAKE2b-256 ced5fd274ffb00ace49387b3de13eb8346f7003ee23b01c2bc8c2737a9e856f4

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