Skip to main content

No project description provided

Project description

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for onlytld, version 0.0.6
Filename, size File type Python version Upload date Hashes
Filename, size onlytld-0.0.6-py3-none-any.whl (80.4 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size onlytld-0.0.6.tar.gz (79.5 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page