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

Commit 8e2d0f7

Browse files
committed
update to 1.20231115.1
1 parent 9457074 commit 8e2d0f7

File tree

17 files changed

+541
-150
lines changed

17 files changed

+541
-150
lines changed

README.md

Lines changed: 71 additions & 106 deletions
Original file line numberDiff line numberDiff line change
@@ -1,141 +1,106 @@
1-
# whois
2-
* A Python package for retrieving WHOIS information of domains.
3-
* This package will not support querying ip CIDR ranges or AS information
4-
* It requires the whois cli component of your os to be installed: e.g. `/usr/bin/whois` on Linux
5-
6-
## NOTE
7-
* 2023-04-25: mboot
8-
* when DannyCork returns he can decide on the future of this repo.
9-
* in his absence future development will take place in: https://github.com/mboot-github/WhoisDomain
10-
* and new pypi releases will come from: https://pypi.org/project/whoisdomain/
11-
* efforts will be made to keep the v1.x.y version of whoisdomain compatible with this repo
12-
* changes will be verified and back copied also here for the time being
13-
* starting 2024-02, this repo will be abandon-ware
14-
15-
## Support
16-
* Python 3.x is supported for x >= 9
17-
* Python 2.x IS NOT supported.
1+
# whoisdomain
182

3+
* A Python package for retrieving WHOIS information of DOMAIN'S ONLY.
4+
* Python 2.x IS NOT supported.
5+
* Currently no additional python packages need to be installed.
196

20-
## Features
21-
* Python wrapper for the "whois" cli command of your operating system.
22-
* Simple interface to access parsed WHOIS data for a given domain.
23-
* Able to extract data for all the popular TLDs (com, org, net, biz, info, pl, jp, uk, nz, ...).
24-
* Query a WHOIS server directly instead of going through an intermediate web service like many others do.
25-
* Works with Python >= 3.9
26-
* All dates as datetime objects.
27-
* Possibility to cache results.
28-
* Verbose output on stderr during debugging to see how the internal functions are doing their work
29-
* raise a exception on Quota ecceeded type responses
30-
* raise a exception on PrivateRegistry tld's where we know the tld and know we don't know anything
31-
* allow for optional cleaning the whois response before extracting information
32-
* optionally allow IDN's to be translated to Punycode
33-
* optional specify the whois command on query(...,cmd="whois") as in: https://github.com/gen1us2k/python-whois/
34-
35-
## Dependencies
36-
* please install also the command line "whois" of your distribution
37-
* this library parses the output of the "whois" cli command of your operating system
7+
---
388

39-
## Docker
40-
* docker pull mbootgithub/whoisdomain:latest
9+
## Notes
4110

42-
## Help Wanted
43-
Your contributions are welcome, look for the Help wanted tag https://github.com/DannyCork/python-whois/labels/help%20wanted
11+
* This package will not support querying ip CIDR ranges or AS information
12+
* This was a copy of the original DanyCork 'whois'.
13+
* Significantly refactored in 2023.
14+
* The output is still compatible with DanyCork 'whois'
4415

45-
## Usage example
16+
## Versioning
4617

47-
Install the cli `whois` of your operating system if it is not present already
18+
* I will start versioning at 1.x.x
19+
* the second item will be YYYYMMDD,
20+
* the third item will start from 1 and be only used if more than one update will have to be done in one day.
4821

49-
Install `whois` package from your distribution (e.g apt install whois)
22+
Versions `1.x.x` will keep the output compatible with Danny Cork until 2024-02-03 (February 2024)
5023

24+
## Releases
5125

52-
$pip install whois
26+
* Releases are avalable at: [Pypi](https://pypi.org/project/whoisdomain/)
5327

54-
>>> import whois
55-
>>> domain = whois.query('google.com')
28+
Pypi releases can be installed with:
5629

57-
>>> print(domain.__dict__)
58-
{
59-
'expiration_date': datetime.datetime(2020, 9, 14, 0, 0),
60-
'last_updated': datetime.datetime(2011, 7, 20, 0, 0),
61-
'registrar': 'MARKMONITOR INC.',
62-
'name': 'google.com',
63-
'creation_date': datetime.datetime(1997, 9, 15, 0, 0)
64-
}
30+
* `pip install whoisdomain`
6531

66-
>>> print(domain.name)
67-
google.com
32+
## Features
33+
* See: [Features](docs/Features.md)
6834

69-
>>> print(domain.expiration_date)
70-
2020-09-14 00:00:00
35+
## Dependencies
36+
* please install also the command line "whois" of your distribution as this library parses the output of the "whois" cli command of your operating system
7137

72-
## ccTLD & TLD support
73-
see the file: ./whois/tld_regexpr.py
74-
or call whois.validTlds()
38+
### Notes for Mac users
39+
* 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.
40+
* using a brew install whois will give in general better results.
7541

76-
## Issues
77-
* Raise an issue https://github.com/DannyCork/python-whois/issues/new
42+
## Docker release
43+
* See [Docker](docs/Docker.md)
7844

79-
## Changes: 2022-06-09: maarten_boot:
80-
* the returned list of name_servers is now a sorted unique list and not a set
81-
* the help function whois.validTlds() now outputs the true tld with dots
45+
## Usage example
46+
* See [Usage](docs/Usage.md)
8247

83-
## 2022-09-27: maarten_boot
84-
* add test2.py to replace test.py
85-
* ./test2.py -h will show the possible usage
86-
* all tests from the original program are now files in the ./tests directory
87-
* test can be done on all supported tld's with -a or --all and limitest by regex with -r <pattern> or --reg=<pattern>
48+
## whoisdomain
49+
* the cli `whoisdomain` is documented in [whoisdomain-cli](docs/whoisdomain-cli.md)
8850

89-
## 2022-11-04: maarten_boot
90-
* add support for Iana example.com, example.net
51+
## ccTLD & TLD support
9152

92-
## 2022-11-07: maarten_boot
93-
* add testing against static known data in dir: ./testdata/<domain>/output
94-
* test.sh will test all domains in testdata without actually calling whois, the input data is instead read from testdata/<domain>/input
53+
Most `tld's` are now autodetected via IANA root db, see the Analizer directory
54+
and `make suggest`.
9555

96-
## 2022-11-11: maarten_boot
56+
* see the file: [tld_regexpr](./whoisdomain/tldDb/tld_regexpr.py)
57+
* for python use: `whoisdomain.validTlds()`
58+
* for cli use `whoisdomain -S`
9759

98-
* add support for returning the raw data from the whois command: flag include_raw_whois_text
99-
* add support for handling unsupported domains via whois raw text only: flag return_raw_text_for_unsupported_tld
60+
---
10061

101-
## 2023-01-18: sorrowless
62+
## Support
63+
* Python 3.x is supported for x >= 9
64+
* Python 2.x IS NOT supported.
10265

103-
* add an opportunity to specify maximum cache age
66+
## Author's
67+
* See: [Authors](docs/Authors.md)
10468

105-
## 2023-01-25: maarten_boot
69+
---
10670

107-
* convert the tld file to a Dict, we now no longer need a mappper for python keywords or second level domains.
108-
* utf8 level domains also need no mapper anymore an can be added as is with a translation to xn--<something>
109-
* added xn-- tlds for all known utf-8 domains we currently have
110-
* we can now add new domains on the fly or change them: whois.mergeExternalDictWithRegex(aDictToOverride) see example exampleExtend.py
71+
## Updates
72+
* see [Updates](docs/Updates.md) for a full history of changes.
73+
* Only the latest update is mentioned here
11174

112-
## 2023-01-27: maarten_boot
75+
### 1.20230906.1
76+
* introduce parsing based on functions
77+
* allow contextual search in splitted data and plain data
78+
* allow contextual search based on earlier result
79+
* fix a few tld to return the proper registrant string (not nic handle)
11380

114-
* add autodetect via iana tld file (this has only tld's)
115-
* add a central collection of all compiled regexes and reuse them: REG_COLLECTION_BY_KEY in _0_init_tld.py
116-
* refresh testdata now that tld has dot instead of _ if more then one level
117-
* add additional strings meaning domain does not exist
81+
### 1.20230913.1
82+
* if you have installed `tld` (pip install tld) you can enable withPublicSuffix=True to process untill you reach the pseudo tld.
83+
* the public_suffix info is added if available (and if requested)
84+
* example case is: ./test2.py -d www.dublin.airport.aero --withPublicSuffix
11885

119-
## 2023-02-02: maarten_boot
86+
### 1.20230913.3
87+
* fix re.NOFLAGS, it is not compatible with 3.9, it appears in 3.11
12088

121-
* whois.QuotaStringsAdd(str) to add additional strings for over quota detection. whois.QuotaStrings() lists the current configured strings
122-
* whois.NoneStringsAdd(str) to add additional string for NoSuchDomainExists detection (whois.query() retuning None). whois.NoneStrings() lsts the current configured strings
123-
* suppress messages to stderr if not verbose=True
89+
## 1.20230917.1
90+
* prepare work on pylint
91+
* switch to logging: all verbose is currently log.debug(); to show set LOGLEVEL=DEBUG before calling, see Makefile: make test
92+
* experimental: add extractServers: bool default False; when true we will try to extract the "redirect info chain" on rcf1036/whois and jwhois for linux/darwin
93+
* add missing option to query(), test in production environment done
12494

125-
## 2023-07-20: maarten_boot
95+
## 1.20231102.1
96+
* fix from kazet for .pl tld.
12697

127-
* sync with https://github.com/mboot-github/WhoisDomain; 1.20230720.1; (gov.tr), (com.ru, msk.ru, spb.ru), (option to preserve partial output after timeout)
128-
* sync with https://github.com/mboot-github/WhoisDomain; 1.20230720.2; add t_test hint support; fix some server hints
98+
## 1.20231115.1
99+
New tld's and removal of a few tlds no longer supported at iana
129100

130-
## 2023-08-21: mboot-github (maarten_boot)
101+
* abb, bw, bn, crown, crs, fj (does not work), gp (does not work), weir, realtor, post, mw, pf (a strange one), iq (gives timout), mm, int, hm (does not work)
131102

132-
* abandon any python below 3.9 (mypy compatibilities)
133-
* major refactor into more object based approch and parameterContext
134-
* allow custom caching backends (e.g. redis, dbm, ...)
103+
---
135104

136-
## 2023-09-22 see new paramaters in whois/context/parameterContext.oy
105+
## in progress
137106

138-
* Sync with latest whoisdomain
139-
* Allow cleaning up the http(s) info in the status response.
140-
* Allow correlation with tld (pip install tld) public_suffix.
141-
* Allow display of what whois-servers were used until we reach the final item.

docs/Authors.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Author's
2+
3+
* this is a rename copy of original work done in: https://github.com/DannyCork/python-whois
4+
* the project is also related to the project: https://github.com/gen1us2k/python-whois
5+
* both seem derived from a older google.code site: https://code.google.com/archive/p/python-whois
6+
* aside from the original authors, many others already contributed to these repositories
7+
* if authors/contributors prefer to be named explicitly, they can add a line in [Historical.txt](Historical.txt)

docs/Docker.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Docker
2+
3+
[Docker](https://hub.docker.com/r/mbootgithub/whoisdomain)
4+
5+
* docker pull mbootgithub/whoisdomain:latest
6+
* docker run mbootgithub/whoisdomain -V # show version
7+
* docker run mbootgithub/whoisdomain -d google.com # run one domain
8+
* docker run mbootgithub/whoisdomain -a # run all tld
9+
* docker run mbootgithub/whoisdomain -d google.com -j | jq -r . # run one domains , output in json and reformat with jq
10+
* docker run mbootgithub/whoisdomain -d google.com -j | jq -r '.expiration_date' # output only expire date
11+
* docker run mbootgithub/whoisdomain -d google.com -j | jq -r '[ .expiration_date, .creation_date ]

docs/Features.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Features
2+
* Python wrapper for the "whois" cli command of your operating system.
3+
* Simple interface to access parsed WHOIS data for a given domain.
4+
* Able to extract data for all the popular TLDs (com, org, net, biz, info, pl, jp, uk, nz, ...).
5+
* Query a WHOIS server directly instead of going through an intermediate web service like many others do.
6+
* Works with Python >= 3.9
7+
* All dates as datetime objects.
8+
* Possibility to cache results.
9+
* Verbose output on stderr during debugging to see how the internal functions are doing their work
10+
* raise a exception on Quota ecceeded type responses
11+
* raise a exception on PrivateRegistry tld's where we know the tld and know we don't know anything
12+
* allow for optional cleaning the response before extracting information
13+
* optionally allow IDN's to be translated to Punycode
14+
* optional specify the whois command on query(...,cmd="whois") as in: https://github.com/gen1us2k/python-whois/
15+
* the module is now 'mypy --strict' clean
16+
* the module now also exports a cli command domainwhois
17+
* both the module and the cli now support showing the version with lib:whois.getVersion() or cli:whoisdomain -V
18+
* the whoisdomain can now output json data (one per domain: e.g 'whoisdomain -d google.com -j' )
19+
* withRedacted: bool = False has been added to query(), if set to True any redacted fields will now be shown also (also supported in the cli whoisdomain as --withRedacted)
20+
* a analizer directory is presend in the github repo that will be used to look for new IANA tls's currently unsupported but maching known whois servers

docs/Updates.md

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
# Updates
2+
## 1.20230627.2
3+
* add Kenia proper whois server and known second level domains
4+
## 1.20230627.3
5+
* add rw tld proper whois server and second level ; restore mistakenly deleted .toml file
6+
## 1.20230627.3
7+
* additional kenia second level domains
8+
## 1.20230712.2
9+
* tld .edu now can have up to 10 nameservers; remove action on pull request
10+
## 1.20230717.1
11+
* add tld: com.ru, msk.ru, spb.ru (all have a test documented), also update the tld: ru, the newlines are not needed.
12+
## 1.20230717.2
13+
* add option to parse partial result after timout has occurred (parse_partial_response:bool default False); this will need `stdbuf` installed otherwise it will fail
14+
## 1.20230718.3
15+
* fix typo in whois server hint for tld: ru
16+
## 1.20230720.1
17+
* add gov.tr; switch off status:available and status:free as None response, we should not interprete the result by default (we can add a option later)
18+
## 1.20230720.2
19+
* fix server hints for derived second level "xxx.tr", add processing "_test" hints during 'test2.py -a'
20+
* add external caching framework that can be overridden for use of your own caching implementation
21+
* renaming various vars to mak them more verbose
22+
* preparing for capturing all parameters in one object and parring that object around instead of many arguments in methods/functions
23+
* switch to json so we dont need a additional dependency in ParamContext
24+
* finish rework args to ParameterContext, split of domain as file
25+
## 1.20230803.1
26+
* frenzy refactor-release
27+
## 1.20230804.1
28+
* testing
29+
## 1.20230804.2
30+
* testing after remove of leading dot in rw second level domains
31+
## 1.20230804.3
32+
* simplefy cache implementation after feedback from `baderdean`
33+
* "more lembas bread", refactor parse and query
34+
* remove option to typecheck CACHE_STUB, use try/catch/exit instead, does not work when timout happens, removed ;-(
35+
* refactor doQuery create processWhoisDomainRequest, split of lastWhois
36+
## 1.20230806.1
37+
* testing done, prep new release: "more lembas bread"
38+
* bug found with the default timeout: if no timeout is specified the program fails: all pypi releases before 2023-07-17 yanked
39+
## 1.20230807.1
40+
* fix default timeout
41+
* add DummyCache, DBMCache, RedisCache with simple test in testCache.py, testing custom cache options
42+
## 1.20230811.1
43+
* replace type hint | with Union for py3.9 compat; switch off experimental redis tools
44+
* switch off 3.[6-8] minimal is 3.9 we test against
45+
* start working on dataContext;
46+
* add more \_test items; reorder parts of tld_regexpr;
47+
* propagate all meta domains servers as they are not inherited, testing , some domains have been retracted mboot; 2023-08-23;
48+
* add suggestion from baderdean to parse fr domains with more focus on ORGANISATION
49+
* 2023-08-24: mboot: more \_test added to tld
50+
* verify all \_test on whois.nic.<tld> \_test: nic.<tld> fix where needed; remove some abandoned tld's
51+
## 1.20230824.1
52+
* mboot; to combine all new tests and changes, "the galloping Chutzpah release"
53+
## 1.20230824.5
54+
* mboot; fix missing module in whl
55+
* restore python 3.6 test as i still use it on one remaining app with python 3.6 (make testP36)
56+
* finalize verification of all tld's in iana, add test where this can be auto generated from whois.nic.<tld> 2023-08-28; mboot
57+
## 1.20230829.1
58+
* mboot; all \_test now work, using analizer tool to verify that iana tld db web site and tl-regexpr match
59+
* add DEBUG to all verbose strings
60+
* remove tldString and dList and domain , all go via dc (dataContect) now
61+
* run tests and add new TODO
62+
* moving all TLD_RE activities to tldInfo.py, and all exported helper funcs to helpers.py
63+
* thinking about adding more complicated nested regex extractors to target contact info
64+
* start with dependency inject: parser is passed as arg
65+
* add cli interface to dependency inject, rightsize after test
66+
* finish dependency inject move Domain create outside
67+
* prep for other types or regex; all simple regex strings in tld_regexpr.py now need R() around them
68+
* use currying to make all regex strings into function cal in whoisParser.py; all regexes in tld_regexpr.py are now converted on import to function calls via R()
69+
* update tld: sk to use contextual extract, test with google.sk
70+
* add findFromToAndLookForWithFindFirst contextual search based on a previous findFirst, used in "fr" tld, example google.fr, {} is used to add to fromStr
71+
72+
## 1.20230904.1
73+
* only on pypi-test
74+
75+
---
76+
77+
## 1.20230906.1
78+
* introduce parsing based on functions
79+
* allow contextual search in splitted data and plain data
80+
* allow contextual search based on earlier result
81+
* fix a few tld to return the proper registrant string (not nic handle)
82+
* introduce parsing based on functions, 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)
83+
84+
### 1.20230906.1
85+
* introduce parsing based on functions
86+
* allow contextual search in splitted data and plain data
87+
* allow contextual search based on earlier result
88+
* fix a few tld to return the proper registrant string (not nic handle)
89+
90+
### 1.20230913.1
91+
* if you have installed `tld` (pip install tld) you can enable withPublicSuffix=True to process untill you reach the pseudo tld.
92+
* the public_suffix info is added if available (and if requested)
93+
* example case is: ./test2.py -d www.dublin.airport.aero --withPublicSuffix
94+
95+
### 1.20230913.3
96+
* fix re.NOFLAGS, it is not compatible with 3.9, it appears in 3.11
97+
98+
---
99+
100+
## in progress
101+
102+
* prepare work on pylint
103+
* switch to logging: all verbose is currently log.debug(); to show set LOGLEVEL=DEBUG before calling, see Makefile: make test
104+
105+
106+

docs/Usage.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Usage
2+
3+
## Requirements
4+
5+
* Install the cli `whois` of your operating system if it is not present already,
6+
* Debian / Ubuntu:
7+
* `sudo apt install whois`
8+
* Fedora/Centos/Rocky:
9+
* `sudo yum install whois`
10+
11+
## whois used in python (compatible with the Danny Cork version)
12+
13+
### example for fedora 37
14+
15+
16+
sudo yum install whois
17+
pip install whoisdomain
18+
19+
python
20+
# to make it compatible with Danny_Cork whois
21+
>>> import whoisdomain as whois
22+
>>> d = whois.query('google.com')
23+
>>> print(d.__dict__)
24+
25+
{'name': 'google.com', 'tld': 'com', 'registrar': 'MarkMonitor, Inc.', 'registrant_country': 'US', 'creation_date': datetime.datetime(1997, 9, 15, 9, 0), 'expiration_date': datetime.datetime(2028, 9, 13, 9, 0), 'last_updated': datetime.datetime(2019, 9, 9, 17, 39, 4), 'status': 'clientUpdateProhibited (https://www.icann.org/epp#clientUpdateProhibited)', 'statuses': ['clientDeleteProhibited (https://www.icann.org/epp#clientDeleteProhibited)', 'clientTransferProhibited (https://www.icann.org/epp#clientTransferProhibited)', 'clientUpdateProhibited (https://www.icann.org/epp#clientUpdateProhibited)', 'serverDeleteProhibited (https://www.icann.org/epp#serverDeleteProhibited)', 'serverTransferProhibited (https://www.icann.org/epp#serverTransferProhibited)', 'serverUpdateProhibited (https://www.icann.org/epp#serverUpdateProhibited)'], 'dnssec': False, 'name_servers': ['ns1.google.com', 'ns2.google.com', 'ns3.google.com', 'ns4.google.com'], 'registrant': 'Google LLC', 'emails': ['[email protected]', '[email protected]']}
26+
27+
>>> print (d.expiration_date)
28+
2028-09-13 09:00:00
29+
30+
>>> print(d.name)
31+
google.com
32+
33+
>>> print (d.creation_date)
34+
1997-09-15 09:00:00

0 commit comments

Comments
 (0)