ipaddress() method fixed

The ipaddress returns a list of IP addresses associated
with the potential domains found.
This commit is contained in:
Alexandre Dulaunoy 2014-09-03 08:46:58 +02:00
parent 7e328b6d8a
commit fec097149d

View file

@ -144,6 +144,7 @@ class Extract:
"""ipaddress method extracts from the domain list the valid IPv4 addresses""" """ipaddress method extracts from the domain list the valid IPv4 addresses"""
def ipaddress(self, extended=False): def ipaddress(self, extended=False):
if extended is False: if extended is False:
self.ipaddresses = [] self.ipaddresses = []
else: else:
@ -151,15 +152,15 @@ class Extract:
for d in self.domain: for d in self.domain:
try: try:
socket.inet_aton(d) ip = socket.gethostbyname(d)
except: except:
pass continue
if extended is False:
self.ipaddresses.append((ip))
else: else:
if extended is False: orig = self.__origin(ipaddr=ip)
self.ipaddresses.append((d)) self.ipaddresses.add((ip, str(orig)))
else:
orig = self.__origin(ipaddr=d)
self.ipaddresses.add((d, str(orig)))
return self.ipaddresses return self.ipaddresses
@ -279,9 +280,8 @@ if __name__ == "__main__":
print "Ranking:" print "Ranking:"
print c.rankdomain() print c.rankdomain()
print "List of ip addresses:" print "List of ip addresses:"
print c.ipaddress(extended=True) print c.ipaddress(extended=False)
print "Include dot.lu:" print "Include dot.lu:"
print c.include(expression=r'\.lu$') print c.include(expression=r'\.lu$')
print "Exclude dot.lu:" print "Exclude dot.lu:"
print c.exclude(expression=r'\.lu$') print c.exclude(expression=r'\.lu$')