From 80dc03f59cf35533c5faf355b51fc7fff7cf85c9 Mon Sep 17 00:00:00 2001 From: Alexandre Dulaunoy Date: Fri, 22 Aug 2014 08:29:59 +0200 Subject: [PATCH] potentialdomain() is now called at the init To avoid confusion the method name domain() has been renamed to potentialdomain(). --- DomainClassifier/domainclassifier.py | 7 ++++--- DomainClassifier/test.py | 4 ++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/DomainClassifier/domainclassifier.py b/DomainClassifier/domainclassifier.py index 091f6d0..8c28e58 100644 --- a/DomainClassifier/domainclassifier.py +++ b/DomainClassifier/domainclassifier.py @@ -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): diff --git a/DomainClassifier/test.py b/DomainClassifier/test.py index 68e5a73..71c4b92 100644 --- a/DomainClassifier/test.py +++ b/DomainClassifier/test.py @@ -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')