onlyTLD
Just only get TLD from domain. No other function. No non-standard library dependencies.
Because it is simple, it is fast. One million queries only require 2.4s.
How to use
In Python3.5+:
from onlytld import get_tld, get_sld
assert get_tld("abersheeran.com") == "com"
assert get_sld("upload.abersheeran.com") == "abersheeran.com"
Support punycode-encoded domain names: if a punycode-encoded domain is passed in, a punycode-encoded domain will be returned, otherwise a utf8 string will be returned.
Update TLD List
Refer to https://www.publicsuffix.org/list/, you can run onlytld.data.fetch_list regularly in the code or run python -m onlytld.data in crontab.
Use yourself TLD List
Maybe this is useless, but I still set this function.
from onlytld import set_datapath, get_tld
set_datapath(YOUR_FILE_PATH)
assert get_tld("chinese.cn") == "cn"
Why this
There are many libraries in pypi that can get tld, such as publicsuffix2, publicsuffixlist, dnspy, but they have too many functions. I just need a repository that can get tld, and it is best not to have dependencies other than the non-standard library.
Release files for onlytld 0.0.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| onlytld-0.0.6.tar.gz | 79.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| onlytld-0.0.6-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 159.9 kB
Release files / onlytld-0.0.6.tar.gz
| Download URL | onlytld-0.0.6.tar.gz |
|---|---|
| Size | 79.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6096fd86d5823dbd96165f23b5a79a227ddc3a76a8b47b8931377377a4d2abf3
|
|
BLAKE2b-256 checksum How to use checksums |
542d67721e86d2d15610b30ebbab16112d33ad3a281b7d8c6847a947668460a4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.0.3 CPython/3.7.4 Windows/10
|
Release files / onlytld-0.0.6-py3-none-any.whl
| Download URL | onlytld-0.0.6-py3-none-any.whl |
|---|---|
| Size | 80.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
85d1551b5b25e77d21dedbe9e2a9faac8869e48244f6720ff05058185c9753b5
|
|
BLAKE2b-256 checksum How to use checksums |
2d6c162352c7153665ef53adfc27e3251ac8559f5b915044f9771ed71b51a0b2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.0.3 CPython/3.7.4 Windows/10
|