committed support for new .org and .info format #60
authorRichard Penman
Fri, 03 Oct 2014 16:40:07 +0200
changeset 44 5cd71f1dc42b
parent 43 f7bf8d6f0547
child 45 52ce01013731
committed support for new .org and .info format #60
whois/parser.py
--- a/whois/parser.py	Mon Aug 25 15:00:56 2014 +0300
+++ b/whois/parser.py	Fri Oct 03 16:40:07 2014 +0200
@@ -186,6 +186,8 @@
             return WhoisBg(domain, text)
         elif domain.endswith('.рф'):
             return WhoisRf(domain, text)
+        elif domain.endswith('.info'):
+            return WhoisInfo(domain, text)
         else:
             return WhoisEntry(domain, text)
 
@@ -213,6 +215,19 @@
 class WhoisOrg(WhoisEntry):
     """Whois parser for .org domains
     """
+    regex = {
+        'domain_name':      'Domain Name:\s?(.+)',
+        'registrar':        'Registrar:\s?(.+)',
+        'whois_server':     'Whois Server:\s?(.+)', # empty usually
+        'referral_url':     'Referral URL:\s?(.+)', # http url of whois_server: empty usually
+        'updated_date':     'Updated Date:\s?(.+)',
+        'creation_date':    'Creation Date:\s?(.+)',
+        'expiration_date':  'Registry Expiry Date:\s?(.+)',
+        'name_servers':     'Name Server:\s?(.+)', # list of name servers
+        'status':           'Status:\s?(.+)', # list of statuses
+        'emails':           '[\w.-]+@[\w.-]+\.[\w]{2,4}', # list of email addresses
+    }
+    
     def __init__(self, domain, text):
         if text.strip() == 'NOT FOUND':
             raise PywhoisError(text)
@@ -670,3 +685,26 @@
             raise PywhoisError(text)
         else:
             WhoisEntry.__init__(self, domain, text, self.regex)
+
+
+class WhoisInfo(WhoisEntry):
+    """Whois parser for .info domains
+    """
+    regex = {
+        'domain_name':      'Domain Name:\s?(.+)',
+        'registrar':        'Registrar:\s?(.+)',
+        'whois_server':     'Whois Server:\s?(.+)', # empty usually
+        'referral_url':     'Referral URL:\s?(.+)', # http url of whois_server: empty usually
+        'updated_date':     'Updated Date:\s?(.+)',
+        'creation_date':    'Creation Date:\s?(.+)',
+        'expiration_date':  'Registry Expiry Date:\s?(.+)',
+        'name_servers':     'Name Server:\s?(.+)', # list of name servers
+        'status':           'Status:\s?(.+)', # list of statuses
+        'emails':           '[\w.-]+@[\w.-]+\.[\w]{2,4}', # list of email addresses
+    }
+
+    def __init__(self, domain, text):
+        if text.strip() == 'NOT FOUND':
+            raise PywhoisError(text)
+        else:
+            WhoisEntry.__init__(self, domain, text, self.regex)
\ No newline at end of file