mirror of
https://github.com/adulau/DomainClassifier.git
synced 2024-11-22 18:07:07 +00:00
python 2.7 and 3.5 compatibility
This commit is contained in:
parent
388f14df2b
commit
6e2dc62f6b
1 changed files with 10 additions and 3 deletions
|
@ -8,7 +8,14 @@ import re
|
||||||
import dns.resolver
|
import dns.resolver
|
||||||
import IPy
|
import IPy
|
||||||
import socket
|
import socket
|
||||||
import urllib.request
|
|
||||||
|
try:
|
||||||
|
#python 3
|
||||||
|
import urllib.request as urllib
|
||||||
|
except:
|
||||||
|
#python 2
|
||||||
|
import urllib2 as urllib
|
||||||
|
|
||||||
|
|
||||||
__author__ = "Alexandre Dulaunoy"
|
__author__ = "Alexandre Dulaunoy"
|
||||||
__copyright__ = "Copyright 2012-2017, Alexandre Dulaunoy"
|
__copyright__ = "Copyright 2012-2017, Alexandre Dulaunoy"
|
||||||
|
@ -82,9 +89,9 @@ class Extract:
|
||||||
|
|
||||||
def __updatelisttld(self):
|
def __updatelisttld(self):
|
||||||
ianatldlist = "https://data.iana.org/TLD/tlds-alpha-by-domain.txt"
|
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')
|
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")
|
tlds = tlds.split("\n")
|
||||||
for tld in tlds:
|
for tld in tlds:
|
||||||
self.listtld.append(tld.lower())
|
self.listtld.append(tld.lower())
|
||||||
|
|
Loading…
Reference in a new issue