potentialdomain() is now called at the init

To avoid confusion the method name domain() has
been renamed to potentialdomain().
This commit is contained in:
Alexandre Dulaunoy 2014-08-22 08:29:59 +02:00
parent b32ff4a776
commit 80dc03f59c
2 changed files with 6 additions and 5 deletions

View file

@ -30,6 +30,7 @@ class Extract:
self.presolver.lifetime = 1.0
self.bgprankingserver = 'pdns.circl.lu'
self.vdomain = []
self.domain = self.potentialdomain()
"""__origin is a private function to the ASN lookup for an IP address via
the Team Cymru DNS interface. ipadd is a string contain the IP address in a
@ -65,7 +66,7 @@ class Extract:
s.close()
if len(r) > 0:
try: rr = r.split("\n")[1].split(",")
except IndexError: return None
except IndexError: return None
if len(rr) > 1:
rank = rr[1]
return float(rank)
@ -74,12 +75,12 @@ class Extract:
else:
return None
"""domain method extracts potential domains matching any
"""potentialdomain method extracts potential domains matching any
string that is a serie of string with maximun 63 character separated by a
dot. The method used the rawtext defined at the instantiation of the class.
This return a list of a potential domain."""
def domain(self):
def potentialdomain(self):
self.domain = []
domain = re.compile(r'\b([a-zA-Z\d-]{,63}(\.[a-zA-Z\d-]{,63})+)\b')
for x in domain.findall(self.rawtext):

View file

@ -1,7 +1,7 @@
import domainclassifier
c = domainclassifier.Extract( rawtext = "www.xxx.com this is a text with a domain called test@foo.lu another test abc.lu something a.b.c.d.e end of 1.2.3.4 foo.be www.belnet.be http://www.cert.be/ www.public.lu www.allo.lu quuxtest www.eurodns.com something-broken-www.google.com www.google.lu trailing test www.facebook.com www.nic.ru www.youporn.com 8.8.8.8 201.1.1.1")
print c.domain()
c = domainclassifier.Extract( rawtext = "www.xxx.com this is a text with a domain called test@foo.lu another test abc.lu something a.b.c.d.e end of 1.2.3.4 foo.be www.belnet.be http://www.cert.be/ www.public.lu www.allo.lu quuxtest www.eurodns.com something-broken-www.google.com www.google.lu trailing test www.facebook.com www.nic.ru www.youporn.com 8.8.8.8 201.1.1.1", nameservers = ['149.13.33.69'])
#print c.potentialdomain()
print c.validdomain(extended=True)
print "US:"
print c.localizedomain(cc='US')