The tldextract module accurately separates the gTLD and ccTLDs from the registered domain and subdomains of a URL. For example, you may want the ‘www.google’ part of http://www.google.com. This is simple to do by splitting on the ‘.’ and using all but the last split element, however that will not work for URLs with arbitrary numbers of subdomains and country codes, unless you know what all country codes look like. Think http://forums.bbc.co.uk for example.
tldextract can give you the subdomains, domain, and gTLD/ccTLD component of a URL, because it looks up–and caches locally–the currently living TLDs according to iana.org.
>>> import tldextract
>>> ext = tldextract.extract('http://forums.news.cnn.com/')
>>> ext['subdomain'], ext['domain'], ext['tld']
('forums.news', 'cnn', 'com')
>>> ext = tldextract.extract('http://forums.bbc.co.uk/')
>>> ext['subdomain'], ext['domain'], ext['tld']
('forums', 'bbc', 'co.uk')
Metadata
Release files for tldextract 0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| tldextract-0.1.tar.gz | 3.2 kB | Without provenance | Details for tldextract-0.1.tar.gz |
Release files / tldextract-0.1.tar.gz
| Download URL | tldextract-0.1.tar.gz |
|---|---|
| Size | 3.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9b6095ffd073da7593f7c624dcf24bfbba0e07a6ca2fcfa268fb140b073d0ade
|
|
BLAKE2b-256 checksum How to use checksums |
90bbf366fca33da1e33d38ad4b355b8d33b7efb85b5bc7305b73833e9966220d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for tldextract 0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.