Skip to main content

Accurately separate the TLD from the registered domain and subdomains of a URL, using the Public Suffix List.

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', tld='com')
>>> tldextract.extract('http://forums.bbc.co.uk/') # United Kingdom
ExtractResult(subdomain='forums', domain='bbc', tld='co.uk')
>>> tldextract.extract('http://www.worldbank.org.kg/') # Kyrgyzstan
ExtractResult(subdomain='www', domain='worldbank', tld='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.domain
'bbc'
>>> '.'.join(ext[:2]) # rejoin subdomain and domain
'forums.bbc'

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-0.3.2.tar.gz (38.0 kB view details)

Uploaded Source

File details

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

File metadata

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

File hashes

Hashes for tldextract-0.3.2.tar.gz
Algorithm Hash digest
SHA256 8ce553d1b68ca34a916777aaeb55f7752782fee5d1a8bff770aa465e29710175
MD5 073c288d4dcd64f4e05daedad4f11491
BLAKE2b-256 e050ab74b74d2258a350c4da83356f5b74a4366d102e83f759e2b1e4b468009b

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