From 27eb590279b84e06c811f0cc1d3c7b3803805617 Mon Sep 17 00:00:00 2001 From: mboot-github <130295084+mboot-github@users.noreply.github.com> Date: Sat, 3 Feb 2024 12:37:29 +0100 Subject: [PATCH] Final contribution: archive now --- README.md | 15 +++---- docs/README.md | 20 +++++++++ whois/__init__.py | 2 + whois/context/parameterContext.py | 6 +++ whois/main.py | 11 ++++- whois/processWhoisDomainRequest.py | 3 +- whois/tldDb/tld_regexpr.py | 65 +++++++++++++++++++++--------- whois/version.py | 2 +- work/version | 2 +- 9 files changed, 94 insertions(+), 32 deletions(-) create mode 100644 docs/README.md diff --git a/README.md b/README.md index 48c691d..d975006 100644 --- a/README.md +++ b/README.md @@ -3,18 +3,13 @@ * A Python package for retrieving WHOIS information of DOMAIN'S ONLY. +**NOTICE: AS OF 2024-02-03; THIS SOFTWARE IS NOW UNSUPPORTED** + +ALL FURTHER ACTIONS WILL TAKE PLACE AT +[WhoisDomain](https://github.com/mboot-github/WhoisDomain) + For all further info: * see [WhoisDomain](https://github.com/mboot-github/WhoisDomain) * all future development will take place on WhoisDomain -### Notes for Mac users - * it has been observed that the default cli whois on Mac is showing each forward step in its output, this makes parsing the result very unreliable. - * using a brew install whois will give in general better results. - -## Support - * Python 2.x IS NOT supported. - * Python 3.x is supported for x >= 9 - -## Updates - * see the Readme at [WhoisDomain](https://github.com/mboot-github/WhoisDomain) diff --git a/docs/README.md b/docs/README.md new file mode 100644 index 0000000..48c691d --- /dev/null +++ b/docs/README.md @@ -0,0 +1,20 @@ +# github:python-whois +# pypi: whois + + * A Python package for retrieving WHOIS information of DOMAIN'S ONLY. + +For all further info: + + * see [WhoisDomain](https://github.com/mboot-github/WhoisDomain) + * all future development will take place on WhoisDomain + +### Notes for Mac users + * it has been observed that the default cli whois on Mac is showing each forward step in its output, this makes parsing the result very unreliable. + * using a brew install whois will give in general better results. + +## Support + * Python 2.x IS NOT supported. + * Python 3.x is supported for x >= 9 + +## Updates + * see the Readme at [WhoisDomain](https://github.com/mboot-github/WhoisDomain) diff --git a/whois/__init__.py b/whois/__init__.py index 9bc99c5..3613c77 100755 --- a/whois/__init__.py +++ b/whois/__init__.py @@ -213,6 +213,7 @@ def query( withPublicSuffix: bool = False, extractServers: bool = False, stripHttpStatus: bool = False, + noIgnoreWww: bool = False, # if you use pc as argument all above params (except domain are ignored) ) -> Optional[Domain]: # see documentation about paramaters in parameterContext.py @@ -242,6 +243,7 @@ def query( tryInstallMissingWhoisOnWindows=tryInstallMissingWhoisOnWindows, extractServers=extractServers, stripHttpStatus=stripHttpStatus, + noIgnoreWww=noIgnoreWww, ) msg = f"{pc}" diff --git a/whois/context/parameterContext.py b/whois/context/parameterContext.py index db72e62..0b394f0 100755 --- a/whois/context/parameterContext.py +++ b/whois/context/parameterContext.py @@ -140,6 +140,12 @@ "default": false, "optional": true, "help": "strip https://icann.org/epp# from status response" + }, + "noIgnoreWww": { + "type": "bool", + "default": false, + "optional": true, + "help": "if set to true we skip the strip www action" } } """ diff --git a/whois/main.py b/whois/main.py index 6b075ca..8b14fb6 100755 --- a/whois/main.py +++ b/whois/main.py @@ -15,7 +15,8 @@ Dict, ) -import whois +# import whoisdomain as whois # to be compatible with dannycork +import whois # to be compatible with dannycork log = logging.getLogger(__name__) logging.basicConfig(level=os.environ.get("LOGLEVEL", "INFO")) @@ -37,6 +38,7 @@ WithPublicSuffix: bool = False WithExtractServers: bool = False WithStripHttpStatus: bool = False +WithNoIgnoreWww: bool = False class ResponseCleaner: @@ -225,6 +227,7 @@ def testItem( global WithPublicSuffix global WithExtractServers global WithStripHttpStatus + global WithNoIgnoreWww pc = whois.ParameterContext( ignore_returncode=IgnoreReturncode, @@ -236,6 +239,7 @@ def testItem( withPublicSuffix=WithPublicSuffix, extractServers=WithExtractServers, stripHttpStatus=WithStripHttpStatus, + noIgnoreWww=WithNoIgnoreWww, ) # use the new query (can also simply use q2() @@ -545,6 +549,7 @@ def main() -> None: global WithPublicSuffix global WithExtractServers global WithStripHttpStatus + global WithNoIgnoreWww name: str = os.path.basename(sys.argv[0]) if name == "test2.py": @@ -577,6 +582,7 @@ def main() -> None: "withPublicSuffix", "extractServers", "stripHttpStatus", + "withNoIgnoreWww", ], ) except getopt.GetoptError: @@ -698,6 +704,9 @@ def main() -> None: if opt in ("--withPublicSuffix"): WithPublicSuffix = True + if opt in ("--withNoIgnoreWww"): + WithNoIgnoreWww = True + msg = f"{name} SIMPLISTIC: {SIMPLISTIC}" log.debug(msg) diff --git a/whois/processWhoisDomainRequest.py b/whois/processWhoisDomainRequest.py index 198c78d..56b8235 100644 --- a/whois/processWhoisDomainRequest.py +++ b/whois/processWhoisDomainRequest.py @@ -80,7 +80,8 @@ def _internationalizedDomainNameToPunyCode(d: List[str]) -> List[str]: return if self.dc.dList[0] == "www": - self.dc.dList = self.dc.dList[1:] + if self.pc.noIgnoreWww is False: + self.dc.dList = self.dc.dList[1:] if len(self.dc.dList) == 0: self.dc.tldString = None diff --git a/whois/tldDb/tld_regexpr.py b/whois/tldDb/tld_regexpr.py index 839cbb0..f01157a 100644 --- a/whois/tldDb/tld_regexpr.py +++ b/whois/tldDb/tld_regexpr.py @@ -106,33 +106,74 @@ def xStr(what: str, times: int = 1, firstMandatory: bool = True) -> str: "_test": "google.com", } -# United Kingdom - academic sub-domain +ZZ["uk"] = { + "extend": "com", + "_server": "whois.nic.uk", + "registrant": R(r"Registrant:\n\s*(.+)"), + "creation_date": R(r"Registered on:\s*(.+)"), + "expiration_date": R(r"Expiry date:\s*(.+)"), + "updated_date": R(r"Last updated:\s*(.+)"), + "name_servers": R(r"Name servers:%s\n\n" % xStr(r"(?:\n[ \t]+(\S+).*)?", 10)), # capture up to 10 + "status": R(r"Registration status:\n\s*(.+)"), +} + ZZ["ac.uk"] = { "extend": "uk", - "domain_name": R(r"Domain:\n\s?(.+)"), + "_server": "whois.nic.ac.uk", + "domain_name": R(r"Domain:\n([^\n]*)"), "owner": R(r"Domain Owner:\n\s?(.+)"), "registrar": R(r"Registered By:\n\s?(.+)"), - "registrant": R(r"Registered Contact:\n\s*(.+)"), + "registrant": R(r"Registrant Contact:\n([^\n]*)"), + "name_servers": R(r"Servers:%s\n\n" % xStr(r"(?:\n[ \t]+(\S+).*)?", 10)), "expiration_date": R(r"Renewal date:\n\s*(.+)"), "updated_date": R(r"Entry updated:\n\s*(.+)"), "creation_date": R(r"Entry created:\n\s?(.+)"), - "name_servers": R(r"Servers:\s*(.+)\t\n\s*(.+)\t\n"), "_test": "imperial.ac.uk", } ZZ["co.uk"] = { "extend": "uk", + "_server": "whois.nic.uk", "domain_name": R(r"Domain name:\s+(.+)"), + "owner": R(r"Domain Owner:\s+(.+)"), "registrar": R(r"Registrar:\s+(.+)"), + "registrant": R(r"Registrant:\n\s+(.+)"), "status": R(r"Registration status:\s*(.+)"), "creation_date": R(r"Registered on:(.+)"), "expiration_date": R(r"Expiry date:(.+)"), "updated_date": R(r"Last updated:(.+)"), - "owner": R(r"Domain Owner:\s+(.+)"), - "registrant": R(r"Registrant:\n\s+(.+)"), "_test": "livedns.co.uk", } +ZZ["gov.uk"] = { + "extend": "ac.uk", + "_server": "whois.gov.uk", + "_test": "service.gov.uk", +} + +ZZ["org.uk"] = { + "extend": "co.uk", + "_test": "greenpeace.org.uk", +} + +# ltd.uk: no example to test with + +ZZ["me.uk"] = { + "extend": "co.uk", + "_server": "whois.nic.uk", + "_test": "xxx.me.uk", +} + +ZZ["net.uk"] = { + "extend": "co.uk", + "_server": "whois.nic.uk", + "_test": "nic.net.uk", # is actually a expired record it seems +} + +# nhs.uk: may not have a whois server example is scot.nhs.uk or digital.nhs.uk +# plc.uk: no example to test with +# police.uk: no example to test; may not actually have a public whois server + # Armenia ZZ["am"] = { "domain_name": R(r"Domain name:\s+(.+)"), @@ -926,16 +967,6 @@ def xStr(what: str, times: int = 1, firstMandatory: bool = True) -> str: "status": R(r"\nstatus:\s*(.+)"), } -ZZ["uk"] = { - "extend": "com", - "registrant": R(r"Registrant:\n\s*(.+)"), - "creation_date": R(r"Registered on:\s*(.+)"), - "expiration_date": R(r"Expiry date:\s*(.+)"), - "updated_date": R(r"Last updated:\s*(.+)"), - "name_servers": R(r"Name servers:%s\n\n" % xStr(r"(?:\n[ \t]+(\S+).*)?", 10)), # capture up to 10 - "status": R(r"Registration status:\n\s*(.+)"), -} - ZZ["uz"] = { "extend": "com", "domain_name": R(r"Domain Name:\s?(.+)"), @@ -1859,7 +1890,6 @@ def xStr(what: str, times: int = 1, firstMandatory: bool = True) -> str: ZZ["gov"] = {"extend": "com"} ZZ["gov.rw"] = {"extend": "rw"} ZZ["gov.tr"] = {"extend": "com.tr", "_server": "whois.trabis.gov.tr", "_test": "www.turkiye.gov.tr"} -ZZ["gov.uk"] = {"extend": "ac.uk"} ZZ["gq"] = {"extend": "ml", "_server": "whois.domino.gq"} ZZ["graphics"] = {"extend": "_donuts", "_server": "whois.donuts.co"} ZZ["gratis"] = {"extend": "_donuts", "_server": "whois.donuts.co"} @@ -2165,7 +2195,6 @@ def xStr(what: str, times: int = 1, firstMandatory: bool = True) -> str: ZZ["org.ph"] = {"extend": "ph"} ZZ["org.rw"] = {"extend": "rw"} ZZ["org.tr"] = {"extend": "com.tr", "_server": "whois.trabis.gov.tr", "_test": "dergipark.org.tr"} -ZZ["org.uk"] = {"extend": "co.uk"} ZZ["org.ve"] = {"extend": "ve"} ZZ["org.za"] = {"extend": "za", "_server": "org-whois.registry.net.za"} ZZ["org.zw"] = {"extend": "zw"} diff --git a/whois/version.py b/whois/version.py index 3dd1820..723cfd7 100644 --- a/whois/version.py +++ b/whois/version.py @@ -1,2 +1,2 @@ """This module only makes the version available for dynamic versioning""" -VERSION = "0.99.3" +VERSION = "1.20240129.2" diff --git a/work/version b/work/version index d17274b..cf74504 100644 --- a/work/version +++ b/work/version @@ -1 +1 @@ -0.99.3 +1.20240129.2