From fec097149d3eb49a18a1161bcb996bb110153d00 Mon Sep 17 00:00:00 2001 From: Alexandre Dulaunoy Date: Wed, 3 Sep 2014 08:46:58 +0200 Subject: [PATCH] ipaddress() method fixed The ipaddress returns a list of IP addresses associated with the potential domains found. --- DomainClassifier/domainclassifier.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/DomainClassifier/domainclassifier.py b/DomainClassifier/domainclassifier.py index b858d1a..6f7be78 100644 --- a/DomainClassifier/domainclassifier.py +++ b/DomainClassifier/domainclassifier.py @@ -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 + continue + + if extended is False: + self.ipaddresses.append((ip)) else: - if extended is False: - self.ipaddresses.append((d)) - 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$') -