From bc8c032c937650717a70cc890efa77c784a1afb6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81ngel=20Gonz=C3=A1lez?= Date: Fri, 8 Dec 2017 01:55:41 +0100 Subject: [PATCH] Support the "Registrar WHOIS Server" key name for the referral MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The ICANN “Registry Registration Data Directory Services Consistent Labeling and Display Policy” [1] renames the key from "WHOIS Server" to this. Remove duplicate "whois server" entry, as noticed by @devl00p Fixes #131 [1] https://www.icann.org/resources/pages/rdds-labeling-policy-2017-02-01-en --- pythonwhois/net.py | 2 +- pythonwhois/parse.py | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/pythonwhois/net.py b/pythonwhois/net.py index 53f87ba..870130e 100644 --- a/pythonwhois/net.py +++ b/pythonwhois/net.py @@ -61,7 +61,7 @@ def get_whois_raw(domain, server="", previous=None, rfc3490=True, never_cut=Fals new_list = [response] + previous server_list.append(target_server) for line in [x.strip() for x in response.splitlines()]: - match = re.match("(refer|whois server|referral url|whois server|registrar whois):\s*([^\s]+\.[^\s]+)", line, re.IGNORECASE) + match = re.match("(refer|whois server|referral url|registrar whois(?: server)?):\s*([^\s]+\.[^\s]+)", line, re.IGNORECASE) if match is not None: referal_server = match.group(2) if referal_server != server and "://" not in referal_server: # We want to ignore anything non-WHOIS (eg. HTTP) for now. diff --git a/pythonwhois/parse.py b/pythonwhois/parse.py index 66217d6..e8c6313 100644 --- a/pythonwhois/parse.py +++ b/pythonwhois/parse.py @@ -140,7 +140,8 @@ def precompile_regexes(source, flags=0): 'Domain Registrar :\s?(?P.+)', 'Registration Service Provider: (?P.+)', '\tName:\t\s(?P.+)'], - 'whois_server': ['Whois Server:\s?(?P.+)', + 'whois_server': ['Registrar WHOIS Server:\s?(?P.+)', + 'Whois Server:\s?(?P.+)', 'Registrar Whois:\s?(?P.+)'], 'nameservers': ['Name Server:[ ]*(?P[^ ]+)', 'Nameservers:[ ]*(?P[^ ]+)',