whois/parser.py
changeset 44 5cd71f1dc42b
parent 43 f7bf8d6f0547
child 46 b3862a45fdad
equal deleted inserted replaced
43:f7bf8d6f0547 44:5cd71f1dc42b
   184             return WhoisPt(domain, text)
   184             return WhoisPt(domain, text)
   185         elif domain.endswith('.bg'):
   185         elif domain.endswith('.bg'):
   186             return WhoisBg(domain, text)
   186             return WhoisBg(domain, text)
   187         elif domain.endswith('.рф'):
   187         elif domain.endswith('.рф'):
   188             return WhoisRf(domain, text)
   188             return WhoisRf(domain, text)
       
   189         elif domain.endswith('.info'):
       
   190             return WhoisInfo(domain, text)
   189         else:
   191         else:
   190             return WhoisEntry(domain, text)
   192             return WhoisEntry(domain, text)
   191 
   193 
   192 
   194 
   193 class WhoisCom(WhoisEntry):
   195 class WhoisCom(WhoisEntry):
   211 
   213 
   212 
   214 
   213 class WhoisOrg(WhoisEntry):
   215 class WhoisOrg(WhoisEntry):
   214     """Whois parser for .org domains
   216     """Whois parser for .org domains
   215     """
   217     """
       
   218     regex = {
       
   219         'domain_name':      'Domain Name:\s?(.+)',
       
   220         'registrar':        'Registrar:\s?(.+)',
       
   221         'whois_server':     'Whois Server:\s?(.+)', # empty usually
       
   222         'referral_url':     'Referral URL:\s?(.+)', # http url of whois_server: empty usually
       
   223         'updated_date':     'Updated Date:\s?(.+)',
       
   224         'creation_date':    'Creation Date:\s?(.+)',
       
   225         'expiration_date':  'Registry Expiry Date:\s?(.+)',
       
   226         'name_servers':     'Name Server:\s?(.+)', # list of name servers
       
   227         'status':           'Status:\s?(.+)', # list of statuses
       
   228         'emails':           '[\w.-]+@[\w.-]+\.[\w]{2,4}', # list of email addresses
       
   229     }
       
   230     
   216     def __init__(self, domain, text):
   231     def __init__(self, domain, text):
   217         if text.strip() == 'NOT FOUND':
   232         if text.strip() == 'NOT FOUND':
   218             raise PywhoisError(text)
   233             raise PywhoisError(text)
   219         else:
   234         else:
   220             WhoisEntry.__init__(self, domain, text)
   235             WhoisEntry.__init__(self, domain, text)
   668     def __init__(self, domain, text):
   683     def __init__(self, domain, text):
   669         if text.strip() == 'No entries found':
   684         if text.strip() == 'No entries found':
   670             raise PywhoisError(text)
   685             raise PywhoisError(text)
   671         else:
   686         else:
   672             WhoisEntry.__init__(self, domain, text, self.regex)
   687             WhoisEntry.__init__(self, domain, text, self.regex)
       
   688 
       
   689 
       
   690 class WhoisInfo(WhoisEntry):
       
   691     """Whois parser for .info domains
       
   692     """
       
   693     regex = {
       
   694         'domain_name':      'Domain Name:\s?(.+)',
       
   695         'registrar':        'Registrar:\s?(.+)',
       
   696         'whois_server':     'Whois Server:\s?(.+)', # empty usually
       
   697         'referral_url':     'Referral URL:\s?(.+)', # http url of whois_server: empty usually
       
   698         'updated_date':     'Updated Date:\s?(.+)',
       
   699         'creation_date':    'Creation Date:\s?(.+)',
       
   700         'expiration_date':  'Registry Expiry Date:\s?(.+)',
       
   701         'name_servers':     'Name Server:\s?(.+)', # list of name servers
       
   702         'status':           'Status:\s?(.+)', # list of statuses
       
   703         'emails':           '[\w.-]+@[\w.-]+\.[\w]{2,4}', # list of email addresses
       
   704     }
       
   705 
       
   706     def __init__(self, domain, text):
       
   707         if text.strip() == 'NOT FOUND':
       
   708             raise PywhoisError(text)
       
   709         else:
       
   710             WhoisEntry.__init__(self, domain, text, self.regex)