### Installing publicsuffixlist via pip Source: https://github.com/ko-zu/psl/blob/devel/README.md Command to install the publicsuffixlist library using the Python package installer, pip. ```Shell $ pip install publicsuffixlist ``` -------------------------------- ### Using Additional publicsuffixlist Methods in Python Source: https://github.com/ko-zu/psl/blob/devel/README.md Examples of using convenient methods like is_private, is_public, privateparts, and subdomain to query domain properties. ```Python print(psl.is_private("example.com")) # True print(psl.is_public("example.com")) # False print(psl.privateparts("aaa.www.example.com")) # ("aaa", "www", "example.com") print(psl.subdomain("aaa.www.example.com", depth=1)) # "www.example.com" ``` -------------------------------- ### Project Dependencies List - Requirements Source: https://github.com/ko-zu/psl/blob/devel/requirements-dev.txt Lists the external Python packages required for the project to run. These packages are typically installed using pip from a requirements file. ```Requirements requests twine wheel pip setuptools ``` -------------------------------- ### Test Public Suffix - Leading Dot - JavaScript Source: https://github.com/ko-zu/psl/blob/devel/publicsuffixlist/test_psl.txt Tests the `checkPublicSuffix` function with domain names that start with a dot. According to PSL rules, names beginning with a dot are invalid inputs and should result in null. ```JavaScript checkPublicSuffix('.com', null); checkPublicSuffix('.example', null); checkPublicSuffix('.example.com', null); checkPublicSuffix('.example.example', null); ``` -------------------------------- ### Loading a Custom Public Suffix List File in Python Source: https://github.com/ko-zu/psl/blob/devel/README.md Shows how to initialize the PublicSuffixList parser with a custom PSL file provided as a file-like object. ```Python with open("latest_psl.dat", "rb") as f: psl = PublicSuffixList(f) ``` -------------------------------- ### Basic Usage of publicsuffixlist in Python Source: https://github.com/ko-zu/psl/blob/devel/README.md Demonstrates the basic usage of the PublicSuffixList class, including finding public and private suffixes for various domain formats (standard, new TLDs, Unicode, Punycode) and handling case sensitivity. ```Python from publicsuffixlist import PublicSuffixList psl = PublicSuffixList() # Uses built-in PSL file print(psl.publicsuffix("www.example.com")) # "com" # the longest public suffix part print(psl.privatesuffix("www.example.com")) # "example.com" # the shortest domain assigned for a registrant print(psl.privatesuffix("com")) # None # Returns None if no private (non-public) part found print(psl.publicsuffix("www.example.unknownnewtld")) # "unknownnewtld" # New TLDs are valid public suffix by default print(psl.publicsuffix("www.example.香港")) #"香港" # Accepts unicode print(psl.publicsuffix("www.example.xn--j6w193g")) # "xn--j6w193g" # Accepts Punycode IDNs by default print(psl.privatesuffix("WWW.EXAMPLE.COM")) # "example.com" # Returns in lowercase by default print(psl.privatesuffix("WWW.EXAMPLE.COM", keep_case=True)) # "EXAMPLE.COM" # kwarg `keep_case=True` to disable the case conversion ``` -------------------------------- ### Running publicsuffixlist Module Commands Source: https://github.com/ko-zu/psl/blob/devel/README.md Shell commands to execute the built-in test suite and the PSL updater script provided with the publicsuffixlist package. ```Shell $ python -m publicsuffixlist.test ``` ```Shell $ python -m publicsuffixlist.update ``` -------------------------------- ### Handling Binary Domain Parts in publicsuffixlist (Python) Source: https://github.com/ko-zu/psl/blob/devel/README.md Illustrates how to pass domain parts as a tuple of bytes to handle arbitrary or potentially malformed binary data, noting the behavior with IDNs passed this way. ```Python psl.privatesuffix((b"a.a", b"a.example\xff", b"com")) # (b"a.example\xff", b"com") # Note that IDNs must be punycoded when passed as tuple of bytes. psl = PublicSuffixList("例.example") psl.publicsuffix((b"xn--fsq", b"example")) # (b"xn--fsq", b"example") # UTF-8 encoded bytes of "例" do not match. psl.publicsuffix((b"\xe4\xbe\x8b", b"example")) # (b"example",) ``` -------------------------------- ### Test Public Suffix - TLD with 2-Level Rules - JavaScript Source: https://github.com/ko-zu/psl/blob/devel/publicsuffixlist/test_psl.txt Tests the `checkPublicSuffix` function with TLDs ('com', 'uk.com', 'ac') that have specific rules for two-level domains, where the public suffix includes the second level. ```JavaScript checkPublicSuffix('com', null); checkPublicSuffix('example.com', 'example.com'); checkPublicSuffix('b.example.com', 'example.com'); checkPublicSuffix('a.b.example.com', 'example.com'); checkPublicSuffix('uk.com', null); checkPublicSuffix('example.uk.com', 'example.uk.com'); checkPublicSuffix('b.example.uk.com', 'example.uk.com'); checkPublicSuffix('a.b.example.uk.com', 'example.uk.com'); checkPublicSuffix('test.ac', 'test.ac'); ``` -------------------------------- ### Test Public Suffix - IDN Labels (Punycode) - JavaScript Source: https://github.com/ko-zu/psl/blob/devel/publicsuffixlist/test_psl.txt Tests the `checkPublicSuffix` function with Internationalized Domain Names (IDNs) represented in Punycode, ensuring correct processing against the Public Suffix List. ```JavaScript checkPublicSuffix('xn--85x722f.com.cn', 'xn--85x722f.com.cn'); checkPublicSuffix('xn--85x722f.xn--55qx5d.cn', 'xn--85x722f.xn--55qx5d.cn'); checkPublicSuffix('www.xn--85x722f.xn--55qx5d.cn', 'xn--85x722f.xn--55qx5d.cn'); checkPublicSuffix('shishi.xn--55qx5d.cn', 'shishi.xn--55qx5d.cn'); checkPublicSuffix('xn--55qx5d.cn', null); checkPublicSuffix('xn--85x722f.xn--fiqs8s', 'xn--85x722f.xn--fiqs8s'); checkPublicSuffix('www.xn--85x722f.xn--fiqs8s', 'xn--85x722f.xn--fiqs8s'); checkPublicSuffix('shishi.xn--fiqs8s', 'shishi.xn--fiqs8s'); checkPublicSuffix('xn--fiqs8s', null); ``` -------------------------------- ### Test Public Suffix - TLD with Wildcard and Exceptions (ck) - JavaScript Source: https://github.com/ko-zu/psl/blob/devel/publicsuffixlist/test_psl.txt Tests the `checkPublicSuffix` function with a TLD ('ck') that includes a wildcard rule but also specific exceptions that override the wildcard. ```JavaScript checkPublicSuffix('ck', null); checkPublicSuffix('test.ck', null); checkPublicSuffix('b.test.ck', 'b.test.ck'); checkPublicSuffix('a.b.test.ck', 'b.test.ck'); checkPublicSuffix('www.ck', 'www.ck'); checkPublicSuffix('www.www.ck', 'www.ck'); ``` -------------------------------- ### Test Public Suffix - Null Input - JavaScript Source: https://github.com/ko-zu/psl/blob/devel/publicsuffixlist/test_psl.txt Tests the `checkPublicSuffix` function with null input for the domain name. Expects null as the result, indicating no public suffix could be determined. ```JavaScript checkPublicSuffix(null, null); ``` -------------------------------- ### Test Public Suffix - TLD with Single Rule - JavaScript Source: https://github.com/ko-zu/psl/blob/devel/publicsuffixlist/test_psl.txt Tests the `checkPublicSuffix` function with a TLD ('biz') that has only one rule in the Public Suffix List, which is the TLD itself. ```JavaScript checkPublicSuffix('biz', null); checkPublicSuffix('domain.biz', 'domain.biz'); checkPublicSuffix('b.domain.biz', 'domain.biz'); checkPublicSuffix('a.b.domain.biz', 'domain.biz'); ``` -------------------------------- ### Test Public Suffix - IDN Labels (Unicode) - JavaScript Source: https://github.com/ko-zu/psl/blob/devel/publicsuffixlist/test_psl.txt Tests the `checkPublicSuffix` function with Internationalized Domain Names (IDNs) using Unicode characters, ensuring correct handling and conversion (likely internal) for PSL lookup. ```JavaScript checkPublicSuffix('食狮.com.cn', '食狮.com.cn'); checkPublicSuffix('食狮.公司.cn', '食狮.公司.cn'); checkPublicSuffix('www.食狮.公司.cn', '食狮.公司.cn'); checkPublicSuffix('shishi.公司.cn', 'shishi.公司.cn'); checkPublicSuffix('公司.cn', null); checkPublicSuffix('食狮.中国', '食狮.中国'); checkPublicSuffix('www.食狮.中国', '食狮.中国'); checkPublicSuffix('shishi.中国', 'shishi.中国'); checkPublicSuffix('中国', null); ``` -------------------------------- ### Test Public Suffix - US K12 Domains - JavaScript Source: https://github.com/ko-zu/psl/blob/devel/publicsuffixlist/test_psl.txt Tests the `checkPublicSuffix` function with specific domain structures used in the US, particularly related to K12 schools, which have unique rules in the PSL. ```JavaScript checkPublicSuffix('us', null); checkPublicSuffix('test.us', 'test.us'); checkPublicSuffix('www.test.us', 'test.us'); checkPublicSuffix('ak.us', null); checkPublicSuffix('test.ak.us', 'test.ak.us'); checkPublicSuffix('www.test.ak.us', 'www.test.ak.us'); checkPublicSuffix('k12.ak.us', null); checkPublicSuffix('test.k12.ak.us', 'test.k12.ak.us'); checkPublicSuffix('www.test.k12.ak.us', 'www.test.k12.ak.us'); ``` -------------------------------- ### Test Public Suffix - Complex TLD (jp) - JavaScript Source: https://github.com/ko-zu/psl/blob/devel/publicsuffixlist/test_psl.txt Tests the `checkPublicSuffix` function with a complex TLD ('jp') that has various specific rules, including exceptions and different levels, demonstrating the hierarchy and exception handling. ```JavaScript checkPublicSuffix('jp', null); checkPublicSuffix('test.jp', 'test.jp'); checkPublicSuffix('www.test.jp', 'test.jp'); checkPublicSuffix('ac.jp', null); checkPublicSuffix('test.ac.jp', 'test.ac.jp'); checkPublicSuffix('www.test.ac.jp', 'test.ac.jp'); checkPublicSuffix('kyoto.jp', null); checkPublicSuffix('test.kyoto.jp', 'test.kyoto.jp'); checkPublicSuffix('ide.kyoto.jp', null); checkPublicSuffix('b.ide.kyoto.jp', 'b.ide.kyoto.jp'); checkPublicSuffix('a.b.ide.kyoto.jp', 'b.ide.kyoto.jp'); checkPublicSuffix('c.kobe.jp', null); checkPublicSuffix('b.c.kobe.jp', 'b.c.kobe.jp'); checkPublicSuffix('a.b.c.kobe.jp', 'b.c.kobe.jp'); checkPublicSuffix('city.kobe.jp', 'city.kobe.jp'); checkPublicSuffix('www.city.kobe.jp', 'city.kobe.jp'); ``` -------------------------------- ### Test Public Suffix - Non-Internet TLD (Commented) - JavaScript Source: https://github.com/ko-zu/psl/blob/devel/publicsuffixlist/test_psl.txt This commented-out section contains test cases for domain names using TLDs that are listed but are not intended for general internet use (e.g., 'local'). These inputs should typically result in null. ```JavaScript //checkPublicSuffix('local', null); //checkPublicSuffix('example.local', null); //checkPublicSuffix('b.example.local', null); //checkPublicSuffix('a.b.example.local', null); ``` -------------------------------- ### Test Public Suffix - TLD with Wildcard Rule - JavaScript Source: https://github.com/ko-zu/psl/blob/devel/publicsuffixlist/test_psl.txt Tests the `checkPublicSuffix` function with a TLD ('mm') that has a wildcard rule (*.mm) in the Public Suffix List, meaning any domain under .mm is a public suffix. ```JavaScript checkPublicSuffix('mm', null); checkPublicSuffix('c.mm', null); checkPublicSuffix('b.c.mm', 'b.c.mm'); checkPublicSuffix('a.b.c.mm', 'b.c.mm'); ``` -------------------------------- ### Test Public Suffix - Mixed Case - JavaScript Source: https://github.com/ko-zu/psl/blob/devel/publicsuffixlist/test_psl.txt Tests the `checkPublicSuffix` function with domain names containing mixed-case characters. The function should normalize the case to lowercase for the effective domain when determining the public suffix. ```JavaScript checkPublicSuffix('COM', null); checkPublicSuffix('example.COM', 'example.com'); checkPublicSuffix('WwW.example.COM', 'example.com'); ``` -------------------------------- ### Test Public Suffix - Unlisted TLD - JavaScript Source: https://github.com/ko-zu/psl/blob/devel/publicsuffixlist/test_psl.txt Tests the `checkPublicSuffix` function with domain names using a Top-Level Domain (TLD) that is not present in the Public Suffix List. For such TLDs, the TLD itself is considered the public suffix. ```JavaScript checkPublicSuffix('example', null); checkPublicSuffix('example.example', 'example.example'); checkPublicSuffix('b.example.example', 'example.example'); checkPublicSuffix('a.b.example.example', 'example.example'); ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.