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

add tld ga; optional cleaning raw whois output; update readme #209

Merged
merged 5 commits into from
Jun 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ A Python package for retrieving WHOIS information of domains.
* All dates as datetime objects.
* Possibility to cache results.
* Verbose output on stderr during debugging to see how the internal functions are doing their work
* raise a exception on Quota ecceeded type responses
* raise a exception on PrivateRegistry tld's where we know the tld and know we don't know anything
* allow for optional cleaning the whois response before extracting information

## Help Wanted
Your contributions are welcome, look for the Help wanted tag https://github.com/DannyCork/python-whois/labels/help%20wanted
Expand Down
2 changes: 1 addition & 1 deletion test.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ def testDomains(aList):

def main():

testOnlyProblems = True
testOnlyProblems = False

if testOnlyProblems is False:
print("Tld's currently supported")
Expand Down
20 changes: 12 additions & 8 deletions whois/_2_parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ def get_tld_re(tld: str) -> Any:
def cleanupWhoisResponse(
response: str,
verbose: bool = False,
with_cleanup_results: bool = False,
) -> str:
# sometimes the quota exceeded is actually in the % lines (e.g. toplevel .at)

if 0:
if verbose:
Expand All @@ -72,12 +72,16 @@ def cleanupWhoisResponse(

tmp2 = []
for line in tmp:
# cleanup comment lines commonly used by whois
if line.startswith("%"):
if with_cleanup_results is True and line.startswith("%"):
# sometimes the quota exceeded is actually in the % lines (e.g. toplevel .at)
continue

if "REDACTED FOR PRIVACY" in line:
continue

if line.startswith("Terms of Use:"):
continue

tmp2.append(line)

response = "\n".join(tmp2)
Expand All @@ -97,11 +101,11 @@ def do_parse(
) -> Optional[Dict[str, Any]]:
r: Dict[str, Any] = {"tld": tld}

if with_cleanup_results is True:
whois_str = cleanupWhoisResponse(
response=whois_str,
verbose=verbose,
)
whois_str = cleanupWhoisResponse(
response=whois_str,
verbose=verbose,
with_cleanup_results=with_cleanup_results,
)

if whois_str.count("\n") < 5:
if verbose:
Expand Down
6 changes: 6 additions & 0 deletions whois/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@
Map2Underscore = {
".ac.uk": "ac_uk",
".co.il": "co_il",
# uganda
".ca.ug": "ca_ug",
".co.ug": "co_ug",
# th
".co.th": "co_th",
".in.th": "in_th",
Expand All @@ -63,7 +66,10 @@
#
".com.au": "com_au",
".com.sg": "com_sg",
#
".com.tr": "com_tr",
".edu.tr": "edu_tr",
#
".edu.ua": "edu_ua",
# dynamic dns without whois
".hopto.org": "hopto_org",
Expand Down
4 changes: 1 addition & 3 deletions whois/tld_regexpr.py
Original file line number Diff line number Diff line change
Expand Up @@ -1577,10 +1577,7 @@
# (https://www.iana.org/domains/root/db/<tld>.html)

# ba
# duckdns.org
# es
# ga
# li
# pk
# com.pk
# edu.pk
Expand All @@ -1595,6 +1592,7 @@
li = {"extend": "_privateReg"}
tk = {"extend": "_privateReg"}
vn = {"extend": "_privateReg"}
ga = {"extend": "_privateReg"}

hopto_org = {"extend": "_privateReg"} # dynamic dns without any whois
duckdns_org = {"extend": "_privateReg"} # dynamic dns without any whois
Expand Down