forked from john-kurkowski/tldextract
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
76 lines (68 loc) · 2.71 KB
/
setup.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
"""`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.
"""
from setuptools import setup
INSTALL_REQUIRES = ["idna", "requests>=2.1.0", "requests-file>=1.4", "filelock>=3.0.8"]
setup(
name="tldextract",
author="John Kurkowski",
author_email="[email protected]",
description=(
"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."
),
license="BSD-3-Clause",
keywords=(
"tld domain subdomain url parse extract urlparse urlsplit public suffix list"
" publicsuffix publicsuffixlist"
),
url="https://github.com/john-kurkowski/tldextract",
packages=["tldextract"],
include_package_data=True,
python_requires=">=3.7",
long_description=__doc__,
long_description_content_type="text/markdown",
classifiers=[
"Development Status :: 5 - Production/Stable",
"Topic :: Utilities",
"License :: OSI Approved :: BSD License",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
],
entry_points={
"console_scripts": [
"tldextract = tldextract.cli:main",
]
},
setup_requires=["setuptools_scm"],
use_scm_version={
"write_to": "tldextract/_version.py",
},
install_requires=INSTALL_REQUIRES,
)