whois/parser.py
changeset 15 4f652607e4d8
parent 14 2bada1724be7
child 16 098d65e3cce7
equal deleted inserted replaced
14:2bada1724be7 15:4f652607e4d8
   119         	return WhoisFi(domain, text)
   119         	return WhoisFi(domain, text)
   120         elif domain.endswith('.jp'):
   120         elif domain.endswith('.jp'):
   121             return WhoisJp(domain, text)
   121             return WhoisJp(domain, text)
   122         elif domain.endswith('.pl'):
   122         elif domain.endswith('.pl'):
   123             return WhoisPl(domain, text)
   123             return WhoisPl(domain, text)
       
   124         elif domain.endswith('.br'):
       
   125             return WhoisBr(domain,text)
   124         else:
   126         else:
   125             return WhoisEntry(domain, text)
   127             return WhoisEntry(domain, text)
   126 
   128 
   127 
   129 
   128 
   130 
   451     def __init__(self, domain, text):
   453     def __init__(self, domain, text):
   452         if text.strip() == 'No entries found':
   454         if text.strip() == 'No entries found':
   453             raise PywhoisError(text)
   455             raise PywhoisError(text)
   454         else:
   456         else:
   455             WhoisEntry.__init__(self, domain, text, self.regex)
   457             WhoisEntry.__init__(self, domain, text, self.regex)
       
   458 
       
   459 class WhoisBr(WhoisEntry):
       
   460    """Whois parser for .br domains
       
   461    """
       
   462    regex = {
       
   463        'domain':                        'domain:\s*(.+)\n',
       
   464        'owner':                         'owner:\s*([\S ]+)',
       
   465        'ownerid':                       'ownerid:\s*(.+)', 
       
   466        'country':                       'country:\s*(.+)',
       
   467        'owner_c':                       'owner-c:\s*(.+)',
       
   468        'admin_c':                       'admin-c:\s*(.+)',
       
   469        'tech_c':                        'tech-c:\s*(.+)',
       
   470        'billing_c':                     'billing-c:\s*(.+)',
       
   471        'nserver':                       'nserver:\s*(.+)',
       
   472        'nsstat':                        'nsstat:\s*(.+)',
       
   473        'nslastaa':                      'nslastaa:\s*(.+)',
       
   474        'saci':                          'saci:\s*(.+)',
       
   475        'created':                       'created:\s*(.+)',
       
   476        'expires':                       'expires:\s*(.+)',
       
   477        'changed':                       'changed:\s*(.+)',
       
   478        'status':                        'status:\s*(.+)',
       
   479        'nic_hdl_br':                    'nic-hdl-br:\s*(.+)',
       
   480        'person':                        'person:\s*([\S ]+)',
       
   481        'email':                         'e-mail:\s*(.+)',
       
   482    }
       
   483 
       
   484    def __init__(self, domain, text):
       
   485 
       
   486        if 'Not found:' in text:
       
   487            raise PywhoisError(text)
       
   488        else:
       
   489            WhoisEntry.__init__(self, domain, text, self.regex)
       
   490