# HG changeset patch # User Richard Penman # Date 1484012021 -28800 # Node ID b4273400685e11334aecbee8ec589d7e51c718b7 # Parent d024d2328e5139768cb252260347b6d1f7e54738# Parent 3c7fbec1833772d8339d1057366aec914178ab82 Merged in rymdhund/pywhois (pull request #18) Add support for .se, .nu and .is diff -r d024d2328e51 -r b4273400685e whois/parser.py --- a/whois/parser.py Mon Jan 09 17:39:24 2017 +0100 +++ b/whois/parser.py Tue Jan 10 09:33:41 2017 +0800 @@ -46,6 +46,7 @@ '%d/%m/%Y %H:%M:%S', # 23/04/2015 12:00:07 EEST '%d/%m/%Y %H:%M:%S %Z', # 23/04/2015 12:00:07 EEST '%d/%m/%Y %H:%M:%S.%f %Z', # 23/04/2015 12:00:07.619546 EEST + '%B %d %Y', # August 14 2017 ] @@ -241,6 +242,12 @@ return WhoisID(domain, text) elif domain.endswith('.sk'): return WhoisSK(domain, text) + elif domain.endswith('.se'): + return WhoisSe(domain, text) + elif domain.endswith('.nu'): + return WhoisSe(domain, text) + elif domain.endswith('.is'): + return WhoisIs(domain, text) else: return WhoisEntry(domain, text) @@ -1130,3 +1137,45 @@ raise PywhoisError(text) else: WhoisEntry.__init__(self, domain, text, self.regex) + + +class WhoisSe(WhoisEntry): + """Whois parser for .se domains + """ + regex = { + 'domain_name': 'domain\.*: *(.+)', + 'creation_date': 'created\.*: *(.+)', + 'updated_date': 'modified\.*: *(.+)', + 'expiration_date': 'expires\.*: *(.+)', + 'transfer_date': 'transferred\.*: *(.+)', + 'name_servers': 'nserver\.*: *(.+)', # list of name servers + 'dnssec': 'dnssec\.*: *(.+)', + 'status': 'status\.*: *(.+)', # list of statuses + 'registrar': 'registrar: *(.+)', + } + + def __init__(self, domain, text): + if 'not found.' in text: + raise PywhoisError(text) + else: + WhoisEntry.__init__(self, domain, text, self.regex) + + +class WhoisIs(WhoisEntry): + """Whois parser for .se domains + """ + regex = { + 'domain_name': 'domain\.*: *(.+)', + 'name': 'person\.*: *(.+)', + 'address': 'address\.*: *(.+)', + 'creation_date': 'created\.*: *(.+)', + 'expiration_date': 'expires\.*: *(.+)', + 'name_servers': 'nserver\.*: *(.+)', # list of name servers + 'dnssec': 'dnssec\.*: *(.+)', + } + + def __init__(self, domain, text): + if 'No entries found' in text: + raise PywhoisError(text) + else: + WhoisEntry.__init__(self, domain, text, self.regex)