From 7924e56e82b9cff0a09c4d3a263d1f70d31d30a2 Mon Sep 17 00:00:00 2001 From: Sven Slootweg Date: Fri, 21 Sep 2012 05:35:59 +0200 Subject: [PATCH] Update heuristic nameserver regex to remove false positives and partial matches --- pythonwhois/__init__.py | 2 +- test.py | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/pythonwhois/__init__.py b/pythonwhois/__init__.py index 582c3a3..5fcdbf4 100644 --- a/pythonwhois/__init__.py +++ b/pythonwhois/__init__.py @@ -41,7 +41,7 @@ grammar = { 'Record maintained by:\s?(?P.+)', 'Registration Service Provided By:\s?(?P.+)'], 'whois_server': ['Registrar Whois:\s?(?P.+)'], - 'name_servers': ['(?Pd?ns[0-9]+\.([a-z0-9-]+\.)+[a-z0-9]+)', + 'name_servers': ['(?P[a-z]+d?ns[0-9]+\.([a-z0-9-]+\.)+[a-z0-9]+)', '(?P[a-z0-9-]+\.d?ns[0-9]*\.([a-z0-9-]+\.)+[a-z0-9]+)', '(?P([a-z0-9-]+\.)+[a-z0-9]+)(\s+([0-9]{1,3}\.){3}[0-9]{1,3})'], 'emails': ['(?P[\w.-]+@[\w.-]+\.[\w]{2,4})'] diff --git a/test.py b/test.py index 1d96a0a..8a41a47 100644 --- a/test.py +++ b/test.py @@ -9,7 +9,8 @@ testlist = open("testlist.txt").readlines() # if result['updated_date'] is None: # print "WHOIS for %s does not contain an update date?" % line -result = pythonwhois.whois("google.com") +#result = pythonwhois.whois("google.com") +result = pythonwhois.whois(sys.argv[1]) print result #print "Creation date: ",