mirror of
https://github.com/adulau/DomainClassifier.git
synced 2024-11-22 18:07:07 +00:00
ipaddress() method fixed
The ipaddress returns a list of IP addresses associated with the potential domains found.
This commit is contained in:
parent
7e328b6d8a
commit
fec097149d
1 changed files with 9 additions and 9 deletions
|
@ -144,6 +144,7 @@ class Extract:
|
|||
"""ipaddress method extracts from the domain list the valid IPv4 addresses"""
|
||||
|
||||
def ipaddress(self, extended=False):
|
||||
|
||||
if extended is False:
|
||||
self.ipaddresses = []
|
||||
else:
|
||||
|
@ -151,15 +152,15 @@ class Extract:
|
|||
|
||||
for d in self.domain:
|
||||
try:
|
||||
socket.inet_aton(d)
|
||||
ip = socket.gethostbyname(d)
|
||||
except:
|
||||
pass
|
||||
else:
|
||||
continue
|
||||
|
||||
if extended is False:
|
||||
self.ipaddresses.append((d))
|
||||
self.ipaddresses.append((ip))
|
||||
else:
|
||||
orig = self.__origin(ipaddr=d)
|
||||
self.ipaddresses.add((d, str(orig)))
|
||||
orig = self.__origin(ipaddr=ip)
|
||||
self.ipaddresses.add((ip, str(orig)))
|
||||
|
||||
return self.ipaddresses
|
||||
|
||||
|
@ -279,9 +280,8 @@ if __name__ == "__main__":
|
|||
print "Ranking:"
|
||||
print c.rankdomain()
|
||||
print "List of ip addresses:"
|
||||
print c.ipaddress(extended=True)
|
||||
print c.ipaddress(extended=False)
|
||||
print "Include dot.lu:"
|
||||
print c.include(expression=r'\.lu$')
|
||||
print "Exclude dot.lu:"
|
||||
print c.exclude(expression=r'\.lu$')
|
||||
|
||||
|
|
Loading…
Reference in a new issue