Merged in rothi83/pywhois (pull request #6)
authorRichard Penman <richardbp@gmail.com>
Thu, 02 Jun 2016 13:59:46 -0700
changeset 93 acdc2cb09f60
parent 91 4382433c1fe0 (current diff)
parent 92 7d3efe9ad172 (diff)
child 98 3202436d89d0
Merged in rothi83/pywhois (pull request #6) Extended parser.py to parse .ch and .li domains
whois/parser.py
--- a/whois/parser.py	Thu Jun 02 13:58:54 2016 -0700
+++ b/whois/parser.py	Thu Jun 02 13:59:46 2016 -0700
@@ -151,7 +151,7 @@
 
     def __getattr__(self, name):
         return self.get(name)
-        
+
 
     def __str__(self):
         handler = lambda e: str(e)
@@ -226,6 +226,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)
 
@@ -265,7 +269,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)
@@ -320,7 +324,7 @@
                 self['zip_code'], _, self['city'] = lines[2].partition(' ')
             self['country'] = lines[-1]
 
-                
+
 
 class WhoisName(WhoisEntry):
     """Whois parser for .name domains
@@ -994,3 +998,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)