whois/parser.py
changeset 26 e0b929723473
parent 24 16f17c400a70
child 27 2afe979e4f4a
equal deleted inserted replaced
25:f3c0a9a442aa 26:e0b929723473
    29         '%Y-%m-%dT%H:%M:%SZ',       # 2007-01-26T19:10:31Z
    29         '%Y-%m-%dT%H:%M:%SZ',       # 2007-01-26T19:10:31Z
    30         '%Y-%m-%dT%H:%M:%S%z',      # 2013-12-06T08:17:22-0800
    30         '%Y-%m-%dT%H:%M:%S%z',      # 2013-12-06T08:17:22-0800
    31         '%Y-%m-%d %H:%M:%SZ',       # 2000-08-22 18:55:20Z
    31         '%Y-%m-%d %H:%M:%SZ',       # 2000-08-22 18:55:20Z
    32         '%Y-%m-%d %H:%M:%S',        # 2000-08-22 18:55:20
    32         '%Y-%m-%d %H:%M:%S',        # 2000-08-22 18:55:20
    33         '%d %b %Y %H:%M:%S',        # 08 Apr 2013 05:44:00
    33         '%d %b %Y %H:%M:%S',        # 08 Apr 2013 05:44:00
       
    34         '%d/%m/%Y %H:%M:%S.%f %Z',  # 23/04/2015 12:00:07.619546 EEST
    34     ]
    35     ]
    35 
    36 
    36     for known_format in known_formats:
    37     for known_format in known_formats:
    37         try:
    38         try:
    38             s = datetime.strptime(s.strip(), known_format)
    39             s = datetime.strptime(s.strip(), known_format)
   151             return WhoisEu(domain, text)
   152             return WhoisEu(domain, text)
   152         elif domain.endswith('.kr'):
   153         elif domain.endswith('.kr'):
   153             return WhoisKr(domain, text)
   154             return WhoisKr(domain, text)
   154         elif domain.endswith('.pt'):
   155         elif domain.endswith('.pt'):
   155             return WhoisPt(domain, text)
   156             return WhoisPt(domain, text)
       
   157         elif domain.endswith('.bg'):
       
   158             return WhoisBg(domain, text)
   156         else:
   159         else:
   157             return WhoisEntry(domain, text)
   160             return WhoisEntry(domain, text)
   158 
   161 
   159 
   162 
   160 
   163 
   599     def __init__(self, domain, text):
   602     def __init__(self, domain, text):
   600         if text.strip() == 'No entries found':
   603         if text.strip() == 'No entries found':
   601             raise PywhoisError(text)
   604             raise PywhoisError(text)
   602         else:
   605         else:
   603             WhoisEntry.__init__(self, domain, text, self.regex)
   606             WhoisEntry.__init__(self, domain, text, self.regex)
       
   607 
       
   608 class WhoisBg(WhoisEntry):
       
   609     """Whois parser for .bg domains"""
       
   610 
       
   611     regex = {
       
   612         'expiration_date': 'expires at:\s*(.+)',
       
   613     }
       
   614 
       
   615     def __init__(self, domain, text):
       
   616         if text.strip() == 'No entries found':
       
   617             raise PywhoisError(text)
       
   618         else:
       
   619             WhoisEntry.__init__(self, domain, text, self.regex)