diff --git a/DomainClassifier/domainclassifier.py b/DomainClassifier/domainclassifier.py index b4a2e4a..c6100d1 100644 --- a/DomainClassifier/domainclassifier.py +++ b/DomainClassifier/domainclassifier.py @@ -8,7 +8,14 @@ import re import dns.resolver import IPy import socket -import urllib.request + +try: + #python 3 + import urllib.request as urllib +except: + #python 2 + import urllib2 as urllib + __author__ = "Alexandre Dulaunoy" __copyright__ = "Copyright 2012-2017, Alexandre Dulaunoy" @@ -82,9 +89,9 @@ class Extract: def __updatelisttld(self): ianatldlist = "https://data.iana.org/TLD/tlds-alpha-by-domain.txt" - req = urllib.request.Request(ianatldlist) + req = urllib.Request(ianatldlist) req.add_header('User-Agent', 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:54.0) Gecko/20100101 Firefox/54.0') - tlds = ( urllib.request.urlopen(req).read() ).decode('utf8') + tlds = ( urllib.urlopen(req).read() ).decode('utf8') tlds = tlds.split("\n") for tld in tlds: self.listtld.append(tld.lower())