# HG changeset patch # User Richard # Date 1517860063 0 # Node ID faaa3ce1af3e0f2d8267cb88d9be3dffcfbe4341 # Parent c385321ec3e435fa2b9f3a69b8a95f4ee6118519# Parent 93f6f3021941184eab7dfc0b64a00570530031cc Merged in aseques/pywhois (pull request #31) Add date format used in .ie domains diff -r 93f6f3021941 -r faaa3ce1af3e setup.py --- a/setup.py Sat Jan 27 00:34:23 2018 +0100 +++ b/setup.py Mon Feb 05 19:47:43 2018 +0000 @@ -1,7 +1,7 @@ import sys, os import setuptools -version = '0.6.7' +version = '0.6.8' setuptools.setup( name='python-whois', diff -r 93f6f3021941 -r faaa3ce1af3e whois/__init__.py --- a/whois/__init__.py Sat Jan 27 00:34:23 2018 +0100 +++ b/whois/__init__.py Mon Feb 05 19:47:43 2018 +0000 @@ -33,7 +33,7 @@ if command: # try native whois command r = subprocess.Popen(['whois', domain], stdout=subprocess.PIPE) - text = r.stdout.read() + text = r.stdout.read().decode() else: # try builtin client nic_client = NICClient() diff -r 93f6f3021941 -r faaa3ce1af3e whois/parser.py --- a/whois/parser.py Sat Jan 27 00:34:23 2018 +0100 +++ b/whois/parser.py Mon Feb 05 19:47:43 2018 +0000 @@ -272,6 +272,8 @@ return WhoisCat(domain, text) elif domain.endswith('.ie'): return WhoisIe(domain, text) + elif domain.endswith('.nz'): + return WhoisNz(domain, text) else: return WhoisEntry(domain, text) @@ -1358,3 +1360,29 @@ raise PywhoisError(text) else: WhoisEntry.__init__(self, domain, text, self.regex) + + +class WhoisNz(WhoisEntry): + """Whois parser for .nz domains + """ + regex = { + 'domain_name': 'domain_name:\s*([^\n\r]+)', + 'registrar': 'registrar_name:\s*([^\n\r]+)', + 'updated_date': 'domain_datelastmodified:\s*([^\n\r]+)', + 'creation_date': 'domain_dateregistered:\s*([^\n\r]+)', + 'expiration_date': 'domain_datebilleduntil:\s*([^\n\r]+)', + 'name_servers': 'ns_name_\d*:\s*([^\n\r]+)', # list of name servers + 'status': 'status:\s*([^\n\r]+)', # list of statuses + 'emails': EMAIL_REGEX, # list of email s + 'name': 'registrant_contact_name:\s*([^\n\r]+)', + 'address': 'registrant_contact_address\d*:\s*([^\n\r]+)', + 'city': 'registrant_contact_city:\s*([^\n\r]+)', + 'zipcode': 'registrant_contact_postalcode:\s*([^\n\r]+)', + 'country': 'registrant_contact_country:\s*([^\n\r]+)', + } + + def __init__(self, domain, text): + if 'no matching objects' in text: + raise PywhoisError(text) + else: + WhoisEntry.__init__(self, domain, text, self.regex) diff -r 93f6f3021941 -r faaa3ce1af3e whois/whois.py --- a/whois/whois.py Sat Jan 27 00:34:23 2018 +0100 +++ b/whois/whois.py Mon Feb 05 19:47:43 2018 +0000 @@ -75,7 +75,7 @@ whois server for getting contact details. """ nhost = None - match = re.compile('Domain Name: ' + query + '\s*.*?Whois Server: (.*?)\s', flags=re.IGNORECASE|re.DOTALL).search(buf) + match = re.compile('Domain Name: {}\s*.*?Whois Server: (.*?)\s'.format(query), flags=re.IGNORECASE|re.DOTALL).search(buf) if match: nhost = match.groups()[0] # if the whois address is domain.tld/something then