# HG changeset patch # User Richard Penman # Date 1442240030 -3600 # Node ID 2ed54e885571987a1b200ea03a8dac568eb96767 # Parent 56499470d942f59c437a6aa3bced9a080d6c0d59 only focus whois search after find many results, to avoid search failure diff -r 56499470d942 -r 2ed54e885571 setup.py --- a/setup.py Tue Sep 08 11:09:27 2015 +0800 +++ b/setup.py Mon Sep 14 15:13:50 2015 +0100 @@ -1,7 +1,7 @@ import sys, os import setuptools -version = '0.5' +version = '0.5.1' setuptools.setup( name='python-whois', diff -r 56499470d942 -r 2ed54e885571 whois/parser.py --- a/whois/parser.py Tue Sep 08 11:09:27 2015 +0800 +++ b/whois/parser.py Mon Sep 14 15:13:50 2015 +0100 @@ -296,12 +296,13 @@ match = re.compile('Registrar:(.*?)DNSSEC', re.DOTALL).search(text) if match: - lines = match.groups()[0].strip().splitlines() - self.name = lines[0] - self.address = lines[1] + lines = [line.strip() for line in match.groups()[0].strip().splitlines()] + self['name'] = lines[0] + self['address'] = lines[1] if len(lines) == 4: - self.zip_code, _, self.city = lines[2].partition(' ') - self.country = lines[-1] + self['zip_code'], _, self['city'] = lines[2].partition(' ') + self['country'] = lines[-1] + class WhoisName(WhoisEntry): diff -r 56499470d942 -r 2ed54e885571 whois/whois.py --- a/whois/whois.py Tue Sep 08 11:09:27 2015 +0800 +++ b/whois/whois.py Mon Sep 14 15:13:50 2015 +0100 @@ -90,7 +90,7 @@ break return nhost - def whois(self, query, hostname, flags): + def whois(self, query, hostname, flags, many_results=False): """Perform initial lookup with TLD whois server then, if the quick flag is false, search that result for the region-specifc whois server and do a lookup @@ -107,7 +107,7 @@ if hostname == NICClient.DENICHOST: queryBytes = "-T dn,ace -C UTF-8 " + query - elif hostname.endswith(NICClient.QNICHOST_TAIL): + elif hostname.endswith(NICClient.QNICHOST_TAIL) and many_results: queryBytes = '=' + query else: queryBytes = query @@ -121,9 +121,11 @@ break s.close() except socket.error as socketerror: - print 'Error: ', socketerror + print 'Socket Error:', socketerror nhost = None response = enforce_ascii(response) + if 'with "=xxx"' in response: + return self.whois(query, hostname, flags, True) if flags & NICClient.WHOIS_RECURSE and nhost is None: nhost = self.findwhois_server(response.decode(), hostname, query) if nhost is not None: