Skip to content
This repository was archived by the owner on Dec 7, 2022. It is now read-only.

Commit 19088a1

Browse files
committed
Minor Change
1 parent 6c411e8 commit 19088a1

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

utils/main_worker.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -447,16 +447,15 @@ def whois_ip(ip_addr):
447447
# ref: https://ipwhois.readthedocs.io/en/latest/RDAP.html
448448
obj = IPWhois(ip_addr)
449449
results = obj.lookup_rdap(depth=1)
450+
if results["asn_description"] and "NA" not in results["asn_description"]:
451+
contact = results["asn_description"]
450452
except (exceptions.ASNRegistryError, exceptions.WhoisLookupError):
451453
return "No results"
452-
except Exception:
454+
except KeyError:
453455
return None
454456
else:
455457
entity = results["entities"][0]
456-
if results["asn_description"] and "NA" not in results["asn_description"]:
457-
contact = results["asn_description"]
458-
else:
459-
contact = results["objects"][entity]["contact"]["address"][0]["value"].replace("\r\n", ", ")
458+
contact = results["objects"][entity]["contact"]["address"][0]["value"].replace("\r\n", ", ")
460459
return contact.replace("\n", ", ")
461460

462461
@staticmethod

0 commit comments

Comments
 (0)