whois/parser.py
changeset 174 f4ea199eecb2
parent 173 03eaf09581eb
child 181 71c105a37bc1
equal deleted inserted replaced
173:03eaf09581eb 174:f4ea199eecb2
    50     '%d %b %Y %H:%M:%S',        # 08 Apr 2013 05:44:00
    50     '%d %b %Y %H:%M:%S',        # 08 Apr 2013 05:44:00
    51     '%d/%m/%Y %H:%M:%S',     # 23/04/2015 12:00:07 EEST
    51     '%d/%m/%Y %H:%M:%S',     # 23/04/2015 12:00:07 EEST
    52     '%d/%m/%Y %H:%M:%S %Z',     # 23/04/2015 12:00:07 EEST
    52     '%d/%m/%Y %H:%M:%S %Z',     # 23/04/2015 12:00:07 EEST
    53     '%d/%m/%Y %H:%M:%S.%f %Z',  # 23/04/2015 12:00:07.619546 EEST
    53     '%d/%m/%Y %H:%M:%S.%f %Z',  # 23/04/2015 12:00:07.619546 EEST
    54     '%B %d %Y',                 # August 14 2017
    54     '%B %d %Y',                 # August 14 2017
       
    55     '%d.%m.%Y %H:%M:%S',        # 08.03.2014 10:28:24
    55 ]
    56 ]
    56 
    57 
    57 
    58 
    58 class PywhoisError(Exception):
    59 class PywhoisError(Exception):
    59     pass
    60     pass
   276             return WhoisNz(domain, text)
   277             return WhoisNz(domain, text)
   277         elif domain.endswith('.space'):
   278         elif domain.endswith('.space'):
   278             return WhoisSpace(domain, text)
   279             return WhoisSpace(domain, text)
   279         elif domain.endswith('.lu'):
   280         elif domain.endswith('.lu'):
   280             return WhoisLu(domain, text)
   281             return WhoisLu(domain, text)
       
   282         elif domain.endswith('.cz'):
       
   283             return WhoisCz(domain, text)
   281         else:
   284         else:
   282             return WhoisEntry(domain, text)
   285             return WhoisEntry(domain, text)
   283 
   286 
   284 
   287 
   285 class WhoisSpace(WhoisEntry):
   288 class WhoisSpace(WhoisEntry):
  1434         if 'No such domain' in text:
  1437         if 'No such domain' in text:
  1435             raise PywhoisError(text)
  1438             raise PywhoisError(text)
  1436         else:
  1439         else:
  1437             WhoisEntry.__init__(self, domain, text, self.regex)
  1440             WhoisEntry.__init__(self, domain, text, self.regex)
  1438 
  1441 
       
  1442 
       
  1443 class WhoisCz(WhoisEntry):
       
  1444     """Whois parser for .cz domains
       
  1445     """
       
  1446     regex = {
       
  1447         'domain_name':              'domain: *(.+)',
       
  1448         'registrant_name':          'registrant: *(.+)',
       
  1449         'registrar':                'registrar: *(.+)',
       
  1450         'creation_date':            'registered: *(.+)',
       
  1451         'updated_date':             'changed: *(.+)',
       
  1452         'expiration_date':          'expire: *(.+)',
       
  1453         'name_servers':             'nserver: *(.+)',
       
  1454     }
       
  1455 
       
  1456     def __init__(self, domain, text):
       
  1457         if '% No entries found.' in text:
       
  1458             raise PywhoisError(text)
       
  1459         else:
       
  1460             WhoisEntry.__init__(self, domain, text, self.regex)
       
  1461