fixed deduplication of lookup history with eq and hash methods added to Lookedup class
This commit is contained in:
parent
11539eda9d
commit
f41816dd5e
@ -32,7 +32,17 @@ class Lookedup(object):
|
||||
self.host_type = determine(self.host)
|
||||
self = self.specific()
|
||||
# TODO: consolidate all below functions if possible
|
||||
# Implement an __eq__ method based on host name: https://dnmtechs.com/comparing-object-instances-by-attributes-in-python-3-a-comprehensive-guide/
|
||||
# DOING: Implement an __eq__ method based on host name: https://dnmtechs.com/comparing-object-instances-by-attributes-in-python-3-a-comprehensive-guide/
|
||||
|
||||
# From: https://stackoverflow.com/questions/14721062/python-comparing-2-lists-of-instances
|
||||
def __hash__(self):
|
||||
return hash((self.host, self.host_type))
|
||||
|
||||
def __eq__(self, other):
|
||||
try:
|
||||
return(self.host, self.host_type) == (other.host, other.host_type)
|
||||
except AttributeError:
|
||||
return NotImplemented
|
||||
|
||||
def url_lookup(self):
|
||||
self.domain = urlparse(self.host).netloc
|
||||
@ -149,7 +159,7 @@ def extract(user_input):
|
||||
# FIX: This function doesn't work for IP addresses, no usable whois() results
|
||||
def domain_info(host):
|
||||
result = dict(whois(host))
|
||||
print("RESULT IS: ", result)
|
||||
# print("RESULT IS: ", result)
|
||||
if result["domain_name"] is not None:
|
||||
if type(result["creation_date"]) is list:
|
||||
result["creation_date"] = result["creation_date"][0].strftime("%d-%m-%Y")
|
||||
|
Loading…
x
Reference in New Issue
Block a user