mboot-github / python-whois

Python module/library for retrieving domain WHOIS information (only domain)
https://pypi.org/project/whois/
MIT License
289 stars 136 forks source link

Most new registered domains has no updated time, Parse error #291

Closed baigreen closed 1 year ago

baigreen commented 1 year ago
Domain Name: [ETH.VLAANDEREN](http://eth.vlaanderen/)
Registry Domain ID: D1000003623-VLAANDER
Registrar WHOIS Server:
Registrar URL: http://www.netim.com/domain/vlaanderen-domain-name.php
Updated Date:
Creation Date: 2023-03-08T17:06:28Z
Registry Expiry Date: 2024-03-08T17:06:28Z
Registrar Registration Expiration Date: 2024-03-08T17:06:28Z
Registrar: NETIM
>>> whois.query("eth.vlaanderen")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/ubuntu/python-whois/whois/__init__.py", line 307, in query
    return Domain(
  File "/home/ubuntu/python-whois/whois/_3_adjust.py", line 57, in __init__
    self.last_updated = str_to_date(data["updated_date"][0], self.tld, verbose=verbose)
  File "/home/ubuntu/python-whois/whois/_3_adjust.py", line 242, in str_to_date
    raise UnknownDateFormat("Unknown date format: '%s'" % text)
whois.exceptions.UnknownDateFormat: Unknown date format: 'creation date: 2023-03-08t17:06:28z'

May add a try except for def "str_to_date" ?

maarten-boot commented 1 year ago

i actually have no errors in the lattest code,

you used the latest git code or the latest pip version ?

>>> import whois
>>> d = whois.query('edu.vlaanderen')
>>> print(d.__dict__)
{'name': 'edu.vlaanderen', 'tld': 'vlaanderen', 'registrar': 'Combell nv', 'registrant_country': 'BE', 'creation_date': datetime.datetime(2015, 2, 22, 9, 34, 48), 'expiration_date': datetime.datetime(2024, 2, 22, 9, 34, 48), 'last_updated': datetime.datetime(2023, 2, 22, 9, 35, 5), 'status': 'ok https://icann.org/epp#OK', 'statuses': ['autoRenewPeriod https://icann.org/epp#autoRenewPeriod', 'ok https://icann.org/epp#OK'], 'dnssec': False, 'name_servers': ['ns3.combell.net', 'ns4.combell.net'], 'registrant': 'Registrant State/Province:', 'emails': ['activation@combell.com']}
maarten-boot commented 1 year ago

my error eth not edu ;-)

maarten-boot commented 1 year ago

the issue is with the existing regex in .com that does not allow for a missing date and gobbles up the next line

fixed with

"creation_date": r"Creation Date:[ \t]*([^\n]*)",
"expiration_date": r"Registry Expiry Date:[ \t]*([^\n]*)",
"updated_date": r"Updated Date:[\t ]*([^\n]*)",

testing now

maarten-boot commented 1 year ago

should be fixed in the current code now

292

maarten-boot commented 1 year ago

./test2.py -d eth.vlaanderen

test domain: <<<<<<<<<< eth.vlaanderen >>>>>>>>>>>>>>>>>>>>
name               str               'eth.vlaanderen'
tld                str               'vlaanderen'
registrar          str               'NETIM'
registrant_country str               'CN'
creation_date      datetime.datetime 2023-03-08 17:06:28
expiration_date    datetime.datetime 2024-03-08 17:06:28
last_updated       NoneType          None
status             str               'ok https://icann.org/epp#OK'
statuses           list              ['addPeriod https://icann.org/epp#addPeriod', 'ok https://icann.org/epp#OK']
dnssec             bool              False
name_servers       list              ['ns1.dan.com', 'ns2.dan.com']
registrant         str               'Registrant State/Province:'
emails             list              ['sales@netim.com']
baigreen commented 1 year ago

Thank you ,sir