diff --git a/Makefile b/Makefile index 002a9b3..1726eca 100644 --- a/Makefile +++ b/Makefile @@ -214,3 +214,6 @@ cleanDist: zz: docker build -t df36 -f Df-36 . docker run -v .:/context df36 -d google.com + +withPublicSuffix: + ./test2.py -d www.dublin.airport.aero --withPublicSuffix diff --git a/README.md b/README.md index 29cf3bd..0aecfb4 100644 --- a/README.md +++ b/README.md @@ -77,3 +77,8 @@ and `make suggest`. * allow contextual search in splitted data and plain data * allow contextual search based on earlier result * fix a few tld to return the proper registrant string (not nic handle) + +### 1.20230913.1 + * if you have installed `tld` (pip install tld) you can enable withPublicSuffix=True to process untill you reach the pseudo tld. + * the public_suffix info is added if available (and if requested) + * example case is: ./test2.py -d www.dublin.airport.aero --withPublicSuffix diff --git a/tests/test-google-tld.py b/tests/test-google-tld.py index f660157..b310b4b 100755 --- a/tests/test-google-tld.py +++ b/tests/test-google-tld.py @@ -32,7 +32,10 @@ def getOneRegistrant( ) -> None: try: print(f"\n### ===: try: {domain}") - w = whoisdomain.query(domain) + w = whoisdomain.query( + domain, + withPublicSuffix=True, + ) except Exception as e: print(domain, e, file=sys.stderr) print(whoisdomain.get_last_raw_whois_data()) @@ -67,7 +70,11 @@ def xMain() -> None: registrants: Dict[str | None, List[str]] = {} for domain in domains: - getOneRegistrant(domain, registrants, verbose) + getOneRegistrant( + domain, + registrants, + verbose, + ) ll = cast(List[str], registrants.keys()) for k in sorted(ll): diff --git a/whoisdomain/__init__.py b/whoisdomain/__init__.py index 34f72c1..7a1230e 100755 --- a/whoisdomain/__init__.py +++ b/whoisdomain/__init__.py @@ -193,6 +193,9 @@ def query( simplistic: bool = False, withRedacted: bool = False, pc: Optional[ParameterContext] = None, + tryInstallMissingWhoisOnWindows: bool = False, + shortResponseLen: int = 5, + withPublicSuffix: bool = False, # if you use pc as argument all above params (except domain are ignored) ) -> Optional[Domain]: # see documentation about paramaters in parameterContext.py @@ -217,6 +220,9 @@ def query( cmd=cmd, simplistic=simplistic, withRedacted=withRedacted, + withPublicSuffix=withPublicSuffix, + shortResponseLen=shortResponseLen, + tryInstallMissingWhoisOnWindows=tryInstallMissingWhoisOnWindows, ) if verbose: diff --git a/whoisdomain/main.py b/whoisdomain/main.py index 6bee8cd..fac108b 100755 --- a/whoisdomain/main.py +++ b/whoisdomain/main.py @@ -29,6 +29,7 @@ IgnoreReturncode: bool = False TestAllTld: bool = False TestRunOnly: bool = False +WithPublicSuffix: bool = False class ResponseCleaner: @@ -215,6 +216,7 @@ def testItem( global TestAllTld global TestRunOnly + global WithPublicSuffix pc = whois.ParameterContext( ignore_returncode=IgnoreReturncode, @@ -223,7 +225,7 @@ def testItem( include_raw_whois_text=PrintGetRawWhoisResult, simplistic=SIMPLISTIC, withRedacted=WithRedacted, - withPublicSuffix=True, # temp + withPublicSuffix=WithPublicSuffix, ) # use the new query (can also simply use q2() @@ -530,6 +532,8 @@ def main() -> None: global WithRedacted global TestAllTld global TestRunOnly + global WithPublicSuffix + name: str = os.path.basename(sys.argv[0]) if name == "test2.py": SIMPLISTIC = False @@ -558,6 +562,7 @@ def main() -> None: "having=", "Cleanup=", "withRedacted", + "withPublicSuffix", ], ) except getopt.GetoptError: @@ -597,6 +602,9 @@ def main() -> None: if opt in ("--withRedacted"): WithRedacted = True + if opt in ("--withPublicSuffix"): + WithPublicSuffix = True + if opt in ("-a", "--all"): TestAllTld = True diff --git a/whoisdomain/processWhoisDomainRequest.py b/whoisdomain/processWhoisDomainRequest.py index 7652e60..4ff1cdb 100644 --- a/whoisdomain/processWhoisDomainRequest.py +++ b/whoisdomain/processWhoisDomainRequest.py @@ -54,7 +54,7 @@ def _internationalizedDomainNameToPunyCode(d: List[str]) -> List[str]: self.dc.domain = self.dc.domain.lower().strip().rstrip(".") # Remove the trailing dot to support FQDN. self.dc.dList = self.dc.domain.split(".") - # test with: www.dublin.airport.aero + # test with: www.dublin.airport.aero see make withPublicSuffix if self.dc.hasLibTld and self.pc.withPublicSuffix: res = libTld.get_tld( self.dc.domain, diff --git a/whoisdomain/version.py b/whoisdomain/version.py index 8c1c755..62d5cc3 100755 --- a/whoisdomain/version.py +++ b/whoisdomain/version.py @@ -1 +1 @@ -VERSION = "1.20230906.1" +VERSION = "1.20230913.1" diff --git a/work/version b/work/version index cf43533..d24fa70 100644 --- a/work/version +++ b/work/version @@ -1 +1 @@ -1.20230906.1 +1.20230913.1