whois/parser.py
changeset 13 f8d7b881701d
parent 12 c57439b500cb
child 14 2bada1724be7
equal deleted inserted replaced
12:c57439b500cb 13:f8d7b881701d
    16     """Convert any date string found in WHOIS to a datetime object.
    16     """Convert any date string found in WHOIS to a datetime object.
    17     """
    17     """
    18     known_formats = [
    18     known_formats = [
    19         '%d-%b-%Y', 				# 02-jan-2000
    19         '%d-%b-%Y', 				# 02-jan-2000
    20         '%Y-%m-%d', 				# 2000-01-02
    20         '%Y-%m-%d', 				# 2000-01-02
    21         '%d.%m.%Y', 				# 2000-01-02
    21         '%d.%m.%Y', 				# 2.1.2000
    22         '%Y.%m.%d',                 # 2000.01.02
    22         '%Y.%m.%d',                 # 2000.01.02
    23         '%Y/%m/%d',                 # 2000/01/02
    23         '%Y/%m/%d',                 # 2000/01/02
    24         '%d-%b-%Y %H:%M:%S %Z',		# 24-Jul-2009 13:20:03 UTC
    24         '%d-%b-%Y %H:%M:%S %Z',		# 24-Jul-2009 13:20:03 UTC
    25         '%a %b %d %H:%M:%S %Z %Y',  # Tue Jun 21 23:59:59 GMT 2011
    25         '%a %b %d %H:%M:%S %Z %Y',  # Tue Jun 21 23:59:59 GMT 2011
    26         '%Y-%m-%dT%H:%M:%SZ',       # 2007-01-26T19:10:31Z
    26         '%Y-%m-%dT%H:%M:%SZ',       # 2007-01-26T19:10:31Z
   420         'registrant_phone':               'phone:\s*([\S\ ]+)',
   420         'registrant_phone':               'phone:\s*([\S\ ]+)',
   421         'status':                         'status:\s*([\S]+)',  # list of statuses
   421         'status':                         'status:\s*([\S]+)',  # list of statuses
   422         'creation_date':                  'created:\s*([\S]+)',
   422         'creation_date':                  'created:\s*([\S]+)',
   423         'updated_date':                   'modified:\s*([\S]+)',
   423         'updated_date':                   'modified:\s*([\S]+)',
   424         'expiration_date':                'expires:\s*([\S]+)',
   424         'expiration_date':                'expires:\s*([\S]+)',
   425         'name_servers':                   'nserver:\s*([\S]+) \[(\S+)\]',  # list of name servers
   425         'name_servers':                   'nserver:\s*([\S]+) \[\S+\]',  # list of name servers
   426         'dnssec':                   'dnssec:\s*([\S]+)',  # list of name servers
   426         'name_server_statuses':           'nserver:\s*([\S]+) \[(\S+)\]',  # list of name servers and statuses
       
   427         'dnssec':                   'dnssec:\s*([\S]+)',
   427 	}
   428 	}
   428     def __init__(self, domain, text):
   429     def __init__(self, domain, text):
   429         if 'Not found:' in text:
   430         if 'Domain not ' in text:
   430             raise PywhoisError(text)
   431             raise PywhoisError(text)
   431         else:
   432         else:
   432             WhoisEntry.__init__(self, domain, text, self.regex)
   433             WhoisEntry.__init__(self, domain, text, self.regex)
   433 
   434 
   434 
   435