publicsuffixlist


Namepublicsuffixlist JSON
Version 0.10.0.20240420 PyPI version JSON
download
home_pagehttps://github.com/ko-zu/psl
Summarypublicsuffixlist implement
upload_time2024-04-20 03:21:59
maintainerNone
docs_urlNone
authorko-zu
requires_python>=2.6
licenseMPL-2.0
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI
coveralls test coverage No coveralls.
            publicsuffixlist
===

[Public Suffix List](https://publicsuffix.org/) parser implementation for Python 2.6+/3.x.

- Compliant with [TEST DATA](https://raw.githubusercontent.com/publicsuffix/list/master/tests/test_psl.txt)
- Support IDN (unicode or punycoded).
- Support Python2.6+ and Python 3.x
- Shipped with built-in PSL and the updater script.
- Written in Pure Python. No library dependencies.

[![Build Status](https://app.travis-ci.com/ko-zu/psl.svg?branch=master)](https://app.travis-ci.com/ko-zu/psl)
[![PyPI version](https://badge.fury.io/py/publicsuffixlist.svg)](https://badge.fury.io/py/publicsuffixlist)
[![Downloads](http://pepy.tech/badge/publicsuffixlist)](http://pepy.tech/project/publicsuffixlist)

Install
===
`publicsuffixlist` can be installed via `pip` or `pip3`.
```
$ sudo pip install publicsuffixlist
```

If you are in a bit old distributions (RHEL/CentOS6.x), you may need to update `pip` itself before install.
```
$ sudo pip install -U pip
```

Usage
===

```python
from publicsuffixlist import PublicSuffixList

psl = PublicSuffixList()
# uses built-in PSL file

psl.publicsuffix("www.example.com")   # "com"
# longest public suffix part

psl.privatesuffix("www.example.com")  # "example.com"
# shortest domain assigned for a registrant

psl.privatesuffix("com") # None
# None if no private (non-public) part found


psl.publicsuffix("www.example.unknownnewtld") # "unknownnewtld"
# new TLDs are valid public suffix by default

psl.publicsuffix(u"www.example.香港")   # u"香港"
# accept unicode

psl.publicsuffix("www.example.xn--j6w193g") # "xn--j6w193g"
# accept punycoded IDNs by default
```

Latest PSL can be passed as a file like line-iterable object.
```python
with open("latest_psl.dat", "rb") as f:
    psl = PublicSuffixList(f)
```

Works with both Python 2.x and 3.x.
```
$ python2 setup.py test
$ python3 setup.py test
```

Drop-in compatibility code to replace [publicsuffix](https://pypi.org/project/publicsuffix/)
```python
# from publicsuffix import PublicSuffixList
from publicsuffixlist.compat import PublicSuffixList

psl = PublicSuffixList()
psl.suffix("www.example.com")   # return "example.com"
psl.suffix("com")               # return "" (as str, not None)
```

Some convenient methods available.
```python
psl.is_private("example.com")  # True
psl.privateparts("aaa.www.example.com") # ("aaa", "www", "example.com")
psl.subdomain("aaa.www.example.com", depth=1) # "www.example.com"
```


Limitation
===
`publicsuffixlist` do NOT provide domain name validation.
In DNS protocol, most of 8-bit characters are acceptable label of domain name. ICANN compliant registries do not accept domain names that have `_` (underscore) but hostname may have. DMARC records, for example.

Users need to confirm the input is valid based on the users' context.

Partially encoded (Unicode-mixed) Punycode is not supported because of very slow Punycode en/decoding and unpredictable encoding of results.
If you are not sure the input is valid Punycode or not, you should do `unknowndomain.encode("idna")` which is idempotence.

ICANN and private suffixes
===
The public suffix list contains both suffixes for ICANN domains and private suffixes. Using the flag `only_icann` the private suffixes can be deactivated:
```
>>> psl = PublicSuffixList()
>>> psl.publicsuffix("example.priv.at")
'priv.at'
>>> psl = PublicSuffixList(only_icann=True)
>>> psl.publicsuffix("example.priv.at")
'at'
```

License
===

- This module is licensed under Mozilla Public License 2.0.
- Public Suffix List maintained by Mozilla Foundation is licensed under Mozilla Public License 2.0.
- PSL testcase dataset is public domain (CC0).


Development / Packaging
===
This module and its packaging workflow are maintained in the author's repository located at https://github.com/ko-zu/psl.
A new package, which includes the latest PSL file, is automatically generated and uploaded to PyPI.
The last part of the version number represents the release date, for instance, `0.10.1.20230331`.


Source / Link
===

- Git repository on GitHub (https://github.com/ko-zu/psl)
- PyPI (https://pypi.org/project/publicsuffixlist/)

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/ko-zu/psl",
    "name": "publicsuffixlist",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=2.6",
    "maintainer_email": null,
    "keywords": null,
    "author": "ko-zu",
    "author_email": "causeless@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/0f/5e/a90b46ab0e95c5b88ae46a59dadcc1150230e83ca55a7585dd59fb2fdd3b/publicsuffixlist-0.10.0.20240420.tar.gz",
    "platform": null,
    "description": "publicsuffixlist\n===\n\n[Public Suffix List](https://publicsuffix.org/) parser implementation for Python 2.6+/3.x.\n\n- Compliant with [TEST DATA](https://raw.githubusercontent.com/publicsuffix/list/master/tests/test_psl.txt)\n- Support IDN (unicode or punycoded).\n- Support Python2.6+ and Python 3.x\n- Shipped with built-in PSL and the updater script.\n- Written in Pure Python. No library dependencies.\n\n[![Build Status](https://app.travis-ci.com/ko-zu/psl.svg?branch=master)](https://app.travis-ci.com/ko-zu/psl)\n[![PyPI version](https://badge.fury.io/py/publicsuffixlist.svg)](https://badge.fury.io/py/publicsuffixlist)\n[![Downloads](http://pepy.tech/badge/publicsuffixlist)](http://pepy.tech/project/publicsuffixlist)\n\nInstall\n===\n`publicsuffixlist` can be installed via `pip` or `pip3`.\n```\n$ sudo pip install publicsuffixlist\n```\n\nIf you are in a bit old distributions (RHEL/CentOS6.x), you may need to update `pip` itself before install.\n```\n$ sudo pip install -U pip\n```\n\nUsage\n===\n\n```python\nfrom publicsuffixlist import PublicSuffixList\n\npsl = PublicSuffixList()\n# uses built-in PSL file\n\npsl.publicsuffix(\"www.example.com\")   # \"com\"\n# longest public suffix part\n\npsl.privatesuffix(\"www.example.com\")  # \"example.com\"\n# shortest domain assigned for a registrant\n\npsl.privatesuffix(\"com\") # None\n# None if no private (non-public) part found\n\n\npsl.publicsuffix(\"www.example.unknownnewtld\") # \"unknownnewtld\"\n# new TLDs are valid public suffix by default\n\npsl.publicsuffix(u\"www.example.\u9999\u6e2f\")   # u\"\u9999\u6e2f\"\n# accept unicode\n\npsl.publicsuffix(\"www.example.xn--j6w193g\") # \"xn--j6w193g\"\n# accept punycoded IDNs by default\n```\n\nLatest PSL can be passed as a file like line-iterable object.\n```python\nwith open(\"latest_psl.dat\", \"rb\") as f:\n    psl = PublicSuffixList(f)\n```\n\nWorks with both Python 2.x and 3.x.\n```\n$ python2 setup.py test\n$ python3 setup.py test\n```\n\nDrop-in compatibility code to replace [publicsuffix](https://pypi.org/project/publicsuffix/)\n```python\n# from publicsuffix import PublicSuffixList\nfrom publicsuffixlist.compat import PublicSuffixList\n\npsl = PublicSuffixList()\npsl.suffix(\"www.example.com\")   # return \"example.com\"\npsl.suffix(\"com\")               # return \"\" (as str, not None)\n```\n\nSome convenient methods available.\n```python\npsl.is_private(\"example.com\")  # True\npsl.privateparts(\"aaa.www.example.com\") # (\"aaa\", \"www\", \"example.com\")\npsl.subdomain(\"aaa.www.example.com\", depth=1) # \"www.example.com\"\n```\n\n\nLimitation\n===\n`publicsuffixlist` do NOT provide domain name validation.\nIn DNS protocol, most of 8-bit characters are acceptable label of domain name. ICANN compliant registries do not accept domain names that have `_` (underscore) but hostname may have. DMARC records, for example.\n\nUsers need to confirm the input is valid based on the users' context.\n\nPartially encoded (Unicode-mixed) Punycode is not supported because of very slow Punycode en/decoding and unpredictable encoding of results.\nIf you are not sure the input is valid Punycode or not, you should do `unknowndomain.encode(\"idna\")` which is idempotence.\n\nICANN and private suffixes\n===\nThe public suffix list contains both suffixes for ICANN domains and private suffixes. Using the flag `only_icann` the private suffixes can be deactivated:\n```\n>>> psl = PublicSuffixList()\n>>> psl.publicsuffix(\"example.priv.at\")\n'priv.at'\n>>> psl = PublicSuffixList(only_icann=True)\n>>> psl.publicsuffix(\"example.priv.at\")\n'at'\n```\n\nLicense\n===\n\n- This module is licensed under Mozilla Public License 2.0.\n- Public Suffix List maintained by Mozilla Foundation is licensed under Mozilla Public License 2.0.\n- PSL testcase dataset is public domain (CC0).\n\n\nDevelopment / Packaging\n===\nThis module and its packaging workflow are maintained in the author's repository located at https://github.com/ko-zu/psl.\nA new package, which includes the latest PSL file, is automatically generated and uploaded to PyPI.\nThe last part of the version number represents the release date, for instance, `0.10.1.20230331`.\n\n\nSource / Link\n===\n\n- Git repository on GitHub (https://github.com/ko-zu/psl)\n- PyPI (https://pypi.org/project/publicsuffixlist/)\n",
    "bugtrack_url": null,
    "license": "MPL-2.0",
    "summary": "publicsuffixlist implement",
    "version": "0.10.0.20240420",
    "project_urls": {
        "Homepage": "https://github.com/ko-zu/psl"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "4390ffd9739b64a2d7dcecb6eddda0003f95ae8ab2ca014b9f72f035454ca213",
                "md5": "894dc1a79437a880f97d3d4bf4a6a559",
                "sha256": "a1844f565c79b88ee78731c7f177dafd8d02d45cedbafb1fd6aa99c0e2c1693a"
            },
            "downloads": -1,
            "filename": "publicsuffixlist-0.10.0.20240420-py2.py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "894dc1a79437a880f97d3d4bf4a6a559",
            "packagetype": "bdist_wheel",
            "python_version": "py2.py3",
            "requires_python": ">=2.6",
            "size": 101075,
            "upload_time": "2024-04-20T03:21:56",
            "upload_time_iso_8601": "2024-04-20T03:21:56.601428Z",
            "url": "https://files.pythonhosted.org/packages/43/90/ffd9739b64a2d7dcecb6eddda0003f95ae8ab2ca014b9f72f035454ca213/publicsuffixlist-0.10.0.20240420-py2.py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "0f5ea90b46ab0e95c5b88ae46a59dadcc1150230e83ca55a7585dd59fb2fdd3b",
                "md5": "d2fcb3c7587330b065738739d4a7e928",
                "sha256": "b3cc4f91eb3fc4595e8ea7ce94c64e3cb98d2bdd9ed932cad7c5199afdff6ba2"
            },
            "downloads": -1,
            "filename": "publicsuffixlist-0.10.0.20240420.tar.gz",
            "has_sig": false,
            "md5_digest": "d2fcb3c7587330b065738739d4a7e928",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=2.6",
            "size": 101205,
            "upload_time": "2024-04-20T03:21:59",
            "upload_time_iso_8601": "2024-04-20T03:21:59.091034Z",
            "url": "https://files.pythonhosted.org/packages/0f/5e/a90b46ab0e95c5b88ae46a59dadcc1150230e83ca55a7585dd59fb2fdd3b/publicsuffixlist-0.10.0.20240420.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-04-20 03:21:59",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "ko-zu",
    "github_project": "psl",
    "travis_ci": true,
    "coveralls": false,
    "github_actions": true,
    "lcname": "publicsuffixlist"
}
        
Elapsed time: 0.25359s