whois/parser.py
changeset 119 3c7fbec18337
parent 117 32947b10adce
child 120 b4273400685e
equal deleted inserted replaced
117:32947b10adce 119:3c7fbec18337
    44     '%Y-%m-%d %H:%M:%S',        # 2000-08-22 18:55:20
    44     '%Y-%m-%d %H:%M:%S',        # 2000-08-22 18:55:20
    45     '%d %b %Y %H:%M:%S',        # 08 Apr 2013 05:44:00
    45     '%d %b %Y %H:%M:%S',        # 08 Apr 2013 05:44:00
    46     '%d/%m/%Y %H:%M:%S',     # 23/04/2015 12:00:07 EEST
    46     '%d/%m/%Y %H:%M:%S',     # 23/04/2015 12:00:07 EEST
    47     '%d/%m/%Y %H:%M:%S %Z',     # 23/04/2015 12:00:07 EEST
    47     '%d/%m/%Y %H:%M:%S %Z',     # 23/04/2015 12:00:07 EEST
    48     '%d/%m/%Y %H:%M:%S.%f %Z',  # 23/04/2015 12:00:07.619546 EEST
    48     '%d/%m/%Y %H:%M:%S.%f %Z',  # 23/04/2015 12:00:07.619546 EEST
       
    49     '%B %d %Y',                 # August 14 2017
    49 ]
    50 ]
    50 
    51 
    51 
    52 
    52 class PywhoisError(Exception):
    53 class PywhoisError(Exception):
    53     pass
    54     pass
   239             return WhoisChLi(domain, text)
   240             return WhoisChLi(domain, text)
   240         elif domain.endswith('.id'):
   241         elif domain.endswith('.id'):
   241             return WhoisID(domain, text)
   242             return WhoisID(domain, text)
   242         elif domain.endswith('.sk'):
   243         elif domain.endswith('.sk'):
   243             return WhoisSK(domain, text)
   244             return WhoisSK(domain, text)
       
   245         elif domain.endswith('.se'):
       
   246             return WhoisSe(domain, text)
       
   247         elif domain.endswith('.nu'):
       
   248             return WhoisSe(domain, text)
       
   249         elif domain.endswith('.is'):
       
   250             return WhoisIs(domain, text)
   244         else:
   251         else:
   245             return WhoisEntry(domain, text)
   252             return WhoisEntry(domain, text)
   246 
   253 
   247 
   254 
   248 class WhoisCom(WhoisEntry):
   255 class WhoisCom(WhoisEntry):
  1128         def __init__(self, domain, text):
  1135         def __init__(self, domain, text):
  1129             if 'NOT FOUND' in text:
  1136             if 'NOT FOUND' in text:
  1130                 raise PywhoisError(text)
  1137                 raise PywhoisError(text)
  1131             else:
  1138             else:
  1132                 WhoisEntry.__init__(self, domain, text, self.regex)
  1139                 WhoisEntry.__init__(self, domain, text, self.regex)
       
  1140 
       
  1141 
       
  1142 class WhoisSe(WhoisEntry):
       
  1143     """Whois parser for .se domains
       
  1144     """
       
  1145     regex = {
       
  1146         'domain_name':                    'domain\.*: *(.+)',
       
  1147         'creation_date':                  'created\.*: *(.+)',
       
  1148         'updated_date':                   'modified\.*: *(.+)',
       
  1149         'expiration_date':                'expires\.*: *(.+)',
       
  1150         'transfer_date':                  'transferred\.*: *(.+)',
       
  1151         'name_servers':                   'nserver\.*: *(.+)',  # list of name servers
       
  1152         'dnssec':                         'dnssec\.*: *(.+)',
       
  1153         'status':                         'status\.*: *(.+)',  # list of statuses
       
  1154         'registrar':                      'registrar: *(.+)',
       
  1155     }
       
  1156 
       
  1157     def __init__(self, domain, text):
       
  1158         if 'not found.' in text:
       
  1159             raise PywhoisError(text)
       
  1160         else:
       
  1161             WhoisEntry.__init__(self, domain, text, self.regex)
       
  1162 
       
  1163 
       
  1164 class WhoisIs(WhoisEntry):
       
  1165     """Whois parser for .se domains
       
  1166     """
       
  1167     regex = {
       
  1168         'domain_name':      'domain\.*: *(.+)',
       
  1169         'name':             'person\.*: *(.+)',
       
  1170         'address':          'address\.*: *(.+)',
       
  1171         'creation_date':    'created\.*: *(.+)',
       
  1172         'expiration_date':  'expires\.*: *(.+)',
       
  1173         'name_servers':     'nserver\.*: *(.+)',  # list of name servers
       
  1174         'dnssec':           'dnssec\.*: *(.+)',
       
  1175     }
       
  1176 
       
  1177     def __init__(self, domain, text):
       
  1178         if 'No entries found' in text:
       
  1179             raise PywhoisError(text)
       
  1180         else:
       
  1181             WhoisEntry.__init__(self, domain, text, self.regex)