From 37be6f0995423d42eb4477a9ebb467250dfb1893 Mon Sep 17 00:00:00 2001 From: Sven Slootweg Date: Thu, 21 Nov 2013 06:48:27 +0100 Subject: [PATCH] jprs.jp support --- pythonwhois/net.py | 6 +++++- pythonwhois/parse.py | 13 +++++++++---- test/data/alibaba.jp | 36 ++++++++++++++++++++++++++++++++++++ 3 files changed, 50 insertions(+), 5 deletions(-) create mode 100644 test/data/alibaba.jp diff --git a/pythonwhois/net.py b/pythonwhois/net.py index 9d31aba..4a99846 100644 --- a/pythonwhois/net.py +++ b/pythonwhois/net.py @@ -7,7 +7,11 @@ def get_whois_raw(domain, server="", previous=[]): target_server = get_root_server(domain) else: target_server = server - response = whois_request(domain, target_server) + if domain.endswith(".jp") and target_server == "whois.jprs.jp": + request_domain = "%s/e" % domain # Suppress Japanese output + else: + request_domain = domain + response = whois_request(request_domain, target_server) new_list = [response] + previous for line in [x.strip() for x in response.splitlines()]: match = re.match("(refer|whois server|referral url|whois server|registrar whois):\s*([^\s]+)", line, re.IGNORECASE) diff --git a/pythonwhois/parse.py b/pythonwhois/parse.py index 7ccef37..a441f77 100644 --- a/pythonwhois/parse.py +++ b/pythonwhois/parse.py @@ -2,9 +2,11 @@ import re, datetime grammar = { "_data": { - 'status': ['Status\s*:\s?(?P.+)', + 'status': ['\[Status\]\s*(?P.+)', + 'Status\s*:\s?(?P.+)', 'state:\s*(?P.+)'], - 'creation_date': ['Creation Date:\s?(?P.+)', + 'creation_date': ['\[Created on\]\s*(?P.+)', + 'Creation Date:\s?(?P.+)', 'Created on:\s?(?P.+)', 'Created on\s?[.]*:\s?(?P.+)\.', 'Date Registered\s?[.]*:\s?(?P.+)', @@ -20,7 +22,8 @@ grammar = { 'Domain Registration Date\s?[.]*:?\s*?(?P.+)', 'created:\s*(?P.+)', 'registered:\s*(?P.+)'], - 'expiration_date': ['Expiration Date:\s?(?P.+)', + 'expiration_date': ['\[Expires on\]\s*(?P.+)', + 'Expiration Date:\s?(?P.+)', 'Expires on:\s?(?P.+)', 'Expires on\s?[.]*:\s?(?P.+)\.', 'Expiry Date\s?[.]*:\s?(?P.+)', @@ -36,7 +39,8 @@ grammar = { 'Domain Expiration Date\s?[.]*:?\s*?(?P.+)', 'paid-till:\s*(?P.+)', 'expire:\s*(?P.+)'], - 'updated_date': ['Updated Date:\s?(?P.+)', + 'updated_date': ['\[Last Updated\]\s*(?P.+)', + 'Updated Date:\s?(?P.+)', #'Database last updated on\s?[.]*:?\s*?(?P.+)\s[a-z]+\.?', 'Record last updated on\s?[.]*:?\s?(?P.+)\.', 'Domain record last updated\s?[.]*:\s*?(?P.+)', @@ -278,6 +282,7 @@ def parse_registrants(data): "Registrant\n (?P.+)\n Email:(?P.+)\n (?P.+)\n(?: (?P.+)\n)? (?P.+) (?P.+)\n (?P.+)\n Tel: (?P.+)\n\n", # internet.bs "Holder of domain name:\n(?P[\S\s]+)\n(?P.+)\n(?P[A-Z0-9-]+)\s+(?P.+)\n(?P.+)\nContractual Language", # nic.ch "\n\n(?:Owner)?\s+: (?P.*)\n(?:\s+: (?P.*)\n)?\s+: (?P.*)\n\s+: (?P.*)\n\s+: (?P.*)\n\s+: (?P.*)\n", # nic.io + "Contact Information:\n\[Name\]\s*(?P.*)\n\[Email\]\s*(?P.*)\n\[Web Page\]\s*(?P.*)\n\[Postal code\]\s*(?P.*)\n\[Postal Address\]\s*(?P.*)\n(?:\s+(?P.*)\n)?(?:\s+(?P.*)\n)?\[Phone\]\s*(?P.*)\n\[Fax\]\s*(?P.*)\n", # jprs.jp "person:\s+(?P.+)", # nic.ru (person) "org:\s+(?P.+)", # nic.ru (organization) ] diff --git a/test/data/alibaba.jp b/test/data/alibaba.jp new file mode 100644 index 0000000..8f2d9a2 --- /dev/null +++ b/test/data/alibaba.jp @@ -0,0 +1,36 @@ +[ JPRS database provides information on network administration. Its use is ] +[ restricted to network administration purposes. For further information, ] +[ use 'whois -h whois.jprs.jp help'. To suppress Japanese output, add'/e' ] +[ at the end of command, e.g. 'whois -h whois.jprs.jp xxx/e'. ] + +Domain Information: +[Domain Name] ALIBABA.JP + +[Registrant] Alibaba Group Holding Limited + +[Name Server] ns1.markmonitor.com +[Name Server] ns6.markmonitor.com +[Name Server] ns4.markmonitor.com +[Name Server] ns3.markmonitor.com +[Name Server] ns7.markmonitor.com +[Name Server] ns2.markmonitor.com +[Name Server] ns5.markmonitor.com +[Signing Key] + +[Created on] 2001/05/08 +[Expires on] 2014/05/31 +[Status] Active +[Last Updated] 2013/06/01 01:05:07 (JST) + +Contact Information: +[Name] Alibaba Group Holding Limited +[Email] dnsadmin@hk.alibaba-inc.com +[Web Page] +[Postal code] KY1-1103 +[Postal Address] George Town + Fourth Floor, One Capital Place + P.O. Box 847 +[Phone] 85222155100 +[Fax] 85222155200 + +