Skip to content
This repository has been archived by the owner on Feb 3, 2024. It is now read-only.

Commit

Permalink
Final contribution: archive now
Browse files Browse the repository at this point in the history
  • Loading branch information
mboot-github committed Feb 3, 2024
1 parent cb3caa0 commit 27eb590
Show file tree
Hide file tree
Showing 9 changed files with 94 additions and 32 deletions.
15 changes: 5 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
20 changes: 20 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -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)
2 changes: 2 additions & 0 deletions whois/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -242,6 +243,7 @@ def query(
tryInstallMissingWhoisOnWindows=tryInstallMissingWhoisOnWindows,
extractServers=extractServers,
stripHttpStatus=stripHttpStatus,
noIgnoreWww=noIgnoreWww,
)

msg = f"{pc}"
Expand Down
6 changes: 6 additions & 0 deletions whois/context/parameterContext.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
"""
Expand Down
11 changes: 10 additions & 1 deletion whois/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
Expand All @@ -37,6 +38,7 @@
WithPublicSuffix: bool = False
WithExtractServers: bool = False
WithStripHttpStatus: bool = False
WithNoIgnoreWww: bool = False


class ResponseCleaner:
Expand Down Expand Up @@ -225,6 +227,7 @@ def testItem(
global WithPublicSuffix
global WithExtractServers
global WithStripHttpStatus
global WithNoIgnoreWww

pc = whois.ParameterContext(
ignore_returncode=IgnoreReturncode,
Expand All @@ -236,6 +239,7 @@ def testItem(
withPublicSuffix=WithPublicSuffix,
extractServers=WithExtractServers,
stripHttpStatus=WithStripHttpStatus,
noIgnoreWww=WithNoIgnoreWww,
)

# use the new query (can also simply use q2()
Expand Down Expand Up @@ -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":
Expand Down Expand Up @@ -577,6 +582,7 @@ def main() -> None:
"withPublicSuffix",
"extractServers",
"stripHttpStatus",
"withNoIgnoreWww",
],
)
except getopt.GetoptError:
Expand Down Expand Up @@ -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)

Expand Down
3 changes: 2 additions & 1 deletion whois/processWhoisDomainRequest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
65 changes: 47 additions & 18 deletions whois/tldDb/tld_regexpr.py
Original file line number Diff line number Diff line change
Expand Up @@ -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+(.+)"),
Expand Down Expand Up @@ -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?(.+)"),
Expand Down Expand Up @@ -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"}
Expand Down Expand Up @@ -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"}
Expand Down
2 changes: 1 addition & 1 deletion whois/version.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
"""This module only makes the version available for dynamic versioning"""
VERSION = "0.99.3"
VERSION = "1.20240129.2"
2 changes: 1 addition & 1 deletion work/version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.99.3
1.20240129.2

0 comments on commit 27eb590

Please sign in to comment.