whois/parser.py
changeset 21 c0b7560f6446
parent 20 54fb35d6d1ae
child 22 1a6c1830d4bc
equal deleted inserted replaced
20:54fb35d6d1ae 21:c0b7560f6446
    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', 				# 2.1.2000
    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/%m/%Y',                 # 02/01/2013
    24         '%Y. %m. %d.',              # 2000. 01. 02.
    25         '%Y. %m. %d.',              # 2000. 01. 02.
    25         '%Y.%m.%d %H:%M:%S',        # 2014.03.08 10:28:24
    26         '%Y.%m.%d %H:%M:%S',        # 2014.03.08 10:28:24
    26         '%d-%b-%Y %H:%M:%S %Z',		# 24-Jul-2009 13:20:03 UTC
    27         '%d-%b-%Y %H:%M:%S %Z',		# 24-Jul-2009 13:20:03 UTC
    27         '%a %b %d %H:%M:%S %Z %Y',  # Tue Jun 21 23:59:59 GMT 2011
    28         '%a %b %d %H:%M:%S %Z %Y',  # Tue Jun 21 23:59:59 GMT 2011
    28         '%Y-%m-%dT%H:%M:%SZ',       # 2007-01-26T19:10:31Z
    29         '%Y-%m-%dT%H:%M:%SZ',       # 2007-01-26T19:10:31Z
   131         elif domain.endswith('.jp'):
   132         elif domain.endswith('.jp'):
   132             return WhoisJp(domain, text)
   133             return WhoisJp(domain, text)
   133         elif domain.endswith('.pl'):
   134         elif domain.endswith('.pl'):
   134             return WhoisPl(domain, text)
   135             return WhoisPl(domain, text)
   135         elif domain.endswith('.br'):
   136         elif domain.endswith('.br'):
   136             return WhoisBr(domain,text)
   137             return WhoisBr(domain, text)
   137         elif domain.endswith('.eu'):
   138         elif domain.endswith('.eu'):
   138             return WhoisEu(domain,text)
   139             return WhoisEu(domain, text)
   139         elif domain.endswith('.kr'):
   140         elif domain.endswith('.kr'):
   140             return WhoisKr(domain,text)
   141             return WhoisKr(domain, text)
       
   142         elif domain.endswith('.pt'):
       
   143             return WhoisPt(domain, text)
   141         else:
   144         else:
   142             return WhoisEntry(domain, text)
   145             return WhoisEntry(domain, text)
   143 
   146 
   144 
   147 
   145 
   148 
   567             raise PywhoisError(text)
   570             raise PywhoisError(text)
   568         else:
   571         else:
   569             WhoisEntry.__init__(self, domain, text, self.regex)
   572             WhoisEntry.__init__(self, domain, text, self.regex)
   570 
   573 
   571 
   574 
       
   575 class WhoisPt(WhoisEntry):
       
   576     """Whois parser for .pt domains
       
   577     """
       
   578     regex = {
       
   579         'domain_name': 'domain name:\s*(.+)',
       
   580         'creation_date': 'creation date \(dd\/mm\/yyyy\):\s*(.+)',
       
   581         'expiration_date': 'expiration date \(dd\/mm\/yyyy\):\s*(.+)',
       
   582         'name_servers': '\tNS\t(.+).', # list of name servers
       
   583         'status': 'status:\s*(.+)', # list of statuses
       
   584         'emails': '[\w.-]+@[\w.-]+\.[\w]{2,4}', # list of email addresses
       
   585     }
       
   586 
       
   587     def __init__(self, domain, text):
       
   588         if text.strip() == 'No entries found':
       
   589             raise PywhoisError(text)
       
   590         else:
       
   591             WhoisEntry.__init__(self, domain, text, self.regex)