diff -r fc40924ac59b -r 7d3efe9ad172 whois/parser.py --- a/whois/parser.py Thu Mar 17 15:37:34 2016 +0100 +++ b/whois/parser.py Sat Mar 26 18:44:28 2016 +0100 @@ -149,7 +149,7 @@ def __getattr__(self, name): return self.get(name) - + def __str__(self): handler = lambda e: str(e) @@ -222,6 +222,10 @@ return WhoisBiz(domain, text) elif domain.endswith('.mobi'): return WhoisMobi(domain, text) + elif domain.endswith('.ch'): + return WhoisChLi(domain, text) + elif domain.endswith('.li'): + return WhoisChLi(domain, text) else: return WhoisEntry(domain, text) @@ -261,7 +265,7 @@ 'status': 'Status: *(.+)', # list of statuses 'emails': EMAIL_REGEX, # list of email addresses } - + def __init__(self, domain, text): if text.strip() == 'NOT FOUND': raise PywhoisError(text) @@ -316,7 +320,7 @@ self['zip_code'], _, self['city'] = lines[2].partition(' ') self['country'] = lines[-1] - + class WhoisName(WhoisEntry): """Whois parser for .name domains @@ -970,3 +974,22 @@ raise PywhoisError(text) else: WhoisEntry.__init__(self, domain, text, self.regex) + + +class WhoisChLi(WhoisEntry): + """Whois Parser for .ch and .li domains + """ + regex = { + 'domain_name': '\nDomain name:\n*(.+)', + 'registrant': 'Holder of domain name:\n*([\n\s\S]+)\nContractual Language:', + 'registrar': 'Registrar:\n*(.+)', + 'creation_date': 'First registration date:\n*(.+)', + 'dnssec': 'DNSSEC:*([\S]+)', + 'tech-c': 'Technical contact:\n*([\n\s\S]+)\nRegistrar:', + 'name_servers': 'Name servers:\n *([\n\S\s]+)' + } + def __init__(self,domain,text): + if 'We do not have an entry in our database matching your query.' in text: + raise PywhoisError(text) + else: + WhoisEntry.__init__(self, domain, text, self.regex)