secynic / ipwhois

Retrieve and parse whois data for IPv4 and IPv6 addresses
https://ipwhois.readthedocs.io/en/latest
BSD 2-Clause "Simplified" License
555 stars 121 forks source link

AttributeError @ line 554 in rdap.py #284

Closed ewongbb closed 4 years ago

ewongbb commented 4 years ago

I came across this attribute error when doing the following:

x = IPWhois('202.143.89.202').lookup_rdap()

Traceback (most recent call last): File "", line 1, in File "C:\Program Files\Git\python38\Lib\site-packages\ipwhois\ipwhois.py", line 317, in lookup_rdap rdap_data = rdap.lookup( File "C:\Program Files\Git\python38\Lib\site-packages\ipwhois\rdap.py", line 780, in lookup result_net.parse() File "C:\Program Files\Git\python38\Lib\site-packages\ipwhois\rdap.py", line 554, in parse self.vars[v] = self.json[v].strip() AttributeError: 'NoneType' object has no attribute 'strip'

Apparently the information received as 'type' was null. Not entirely sure how to fix this aside for including AttributeError in the following line in rdap.py

        except (KeyError, ValueError, AttributeError):
ewongbb commented 4 years ago

or another option is to:

` try:

self.vars[v] = None
if self.json[v] is not None:
    self.vars[v] = self.json[v].strip()

`

secynic commented 4 years ago

This is already fixed in the dev branch. I tested this IP and did get a different parsing error for NIR: NIR whois field parsing failed for created: time data '2016/05/06' does not match format '%Y/%m/%d %H:%M:%S(JST)'

I'll leave this open to fix that.

ewongbb commented 4 years ago

Thanks and sorry for not seeing the fix on the dev branch.