# HG changeset patch # User Richard # Date 1504217429 0 # Node ID 3ff7f09ea24a813a23b38b33501e2760b088f7bd # Parent 7666f0765fe4084a88eed1232fbf1593f6a19b92# Parent 29e9190319e5e95e95c365817f97b83200853d5f Merged in soulmachine/pywhois (pull request #22) Added support for .ai domains diff -r 7666f0765fe4 -r 3ff7f09ea24a whois/parser.py --- a/whois/parser.py Sun Aug 27 11:22:42 2017 -0300 +++ b/whois/parser.py Thu Aug 31 22:10:29 2017 +0000 @@ -256,6 +256,8 @@ return WhoisDk(domain, text) elif domain.endswith('.it'): return WhoisIt(domain, text) + elif domain.endswith('.ai'): + return WhoisAi(domain, text) else: return WhoisEntry(domain, text) @@ -1216,3 +1218,24 @@ raise PywhoisError(text) else: WhoisEntry.__init__(self, domain, text, self.regex) + +class WhoisAi(WhoisEntry): + """Whois parser for .ai domains + """ + regex = { + 'domain_name': 'Complete Domain Name\.*: *(.+)', + 'name': 'Name \(Last, First\)\.*: *(.+)', + 'org': 'Organization Name\.*: *(.+)', + 'address': 'Street Address\.*: *(.+)', + 'city': 'City\.*: *(.+)', + 'state': 'State\.*: *(.+)', + 'zipcode': 'Postal Code\.*: *(\d+)', + 'country': 'Country\.*: *(.+)', + 'name_servers': 'Server Hostname\.*: *(.+)', + } + + def __init__(self, domain, text): + if 'not registered' in text: + raise PywhoisError(text) + else: + WhoisEntry.__init__(self, domain, text, self.regex) diff -r 7666f0765fe4 -r 3ff7f09ea24a whois/whois.py --- a/whois/whois.py Sun Aug 27 11:22:42 2017 -0300 +++ b/whois/whois.py Thu Aug 31 22:10:29 2017 +0000 @@ -59,6 +59,7 @@ IANAHOST = "whois.iana.org" PANDIHOST = "whois.pandi.or.id" DENICHOST = "de.whois-servers.net" + AI_HOST = "whois.ai" DEFAULT_PORT = "nicname" WHOIS_RECURSE = 0x01 @@ -152,7 +153,10 @@ tld = domain[-1] if tld[0].isdigit(): return NICClient.ANICHOST - return tld + NICClient.QNICHOST_TAIL + elif tld == 'ai': + return NICClient.AI_HOST + else: + return tld + NICClient.QNICHOST_TAIL def whois_lookup(self, options, query_arg, flags): """Main entry point: Perform initial lookup on TLD whois server,