# HG changeset patch # User Richard # Date 1527001843 0 # Node ID 08cfbab35d0b94b6d84a7da971cd4a6571624535 # Parent 06e9b88e0c20c94fd511351185b62cbfc26e64fd# Parent 2fb992c480e465d206e195b38f467ba611a38b01 Merged in kidmose/pywhois/feature/fix-test_parser-keys_to_test (pull request #34) test_parser.py: Respect keys_to_test/Fix error in 7bec7a730d69 diff -r 2fb992c480e4 -r 08cfbab35d0b README.rst --- a/README.rst Fri Feb 16 20:12:48 2018 +0100 +++ b/README.rst Tue May 22 15:10:43 2018 +0000 @@ -72,6 +72,15 @@ OK +SOCKS Proxy support requirements: + +.. sourcecode:: bash + + $ pip install PySocks + ............ + --------------------------------------------------------------------- + $ export SOCKS=socksproxy.someplace.com:8080 + Problems? ========= diff -r 2fb992c480e4 -r 08cfbab35d0b setup.py --- a/setup.py Fri Feb 16 20:12:48 2018 +0100 +++ b/setup.py Tue May 22 15:10:43 2018 +0000 @@ -1,7 +1,7 @@ import sys, os import setuptools -version = '0.6.8' +version = '0.7.0' setuptools.setup( name='python-whois', @@ -17,7 +17,9 @@ 'License :: OSI Approved :: MIT License', 'Operating System :: OS Independent', 'Programming Language :: Python', - 'Topic :: Internet :: WWW/HTTP' + 'Topic :: Internet :: WWW/HTTP', + 'Programming Language :: Python :: 2', + 'Programming Language :: Python :: 3', ], keywords='whois, python', author='Richard Penman', diff -r 2fb992c480e4 -r 08cfbab35d0b whois/parser.py --- a/whois/parser.py Fri Feb 16 20:12:48 2018 +0100 +++ b/whois/parser.py Tue May 22 15:10:43 2018 +0000 @@ -52,6 +52,7 @@ '%d/%m/%Y %H:%M:%S %Z', # 23/04/2015 12:00:07 EEST '%d/%m/%Y %H:%M:%S.%f %Z', # 23/04/2015 12:00:07.619546 EEST '%B %d %Y', # August 14 2017 + '%d.%m.%Y %H:%M:%S', # 08.03.2014 10:28:24 ] @@ -276,6 +277,10 @@ return WhoisNz(domain, text) elif domain.endswith('.space'): return WhoisSpace(domain, text) + elif domain.endswith('.lu'): + return WhoisLu(domain, text) + elif domain.endswith('.cz'): + return WhoisCz(domain, text) else: return WhoisEntry(domain, text) @@ -544,7 +549,7 @@ 'domain_name': 'Domain Name:(.+)', 'creation_date': 'Creation Date:(.+)', 'updated_date': 'Updated Date:(.+)', - 'expiration_date': 'Registry Expiry Date: :(.+)', + 'expiration_date': 'Registry Expiry Date: (.+)', 'registrar': 'Registrar:(.+)', 'status': 'Domain Status:(.+)', # list of statuses 'registrant_id': 'Registrant ID:(.+)', @@ -627,6 +632,8 @@ class WhoisFr(WhoisEntry): """Whois parser for .fr domains """ + dayfirst = True + regex = { 'domain_name': 'domain: *(.+)', 'registrar': 'registrar: *(.+)', @@ -719,7 +726,7 @@ 'tech_fax': r'Technical: *Name: *[^\n\r]+\s*Organisation: *[^\n\r]+\s*Language: *[^\n\r]+\s*Phone: *[^\n\r]+\s*Fax: *([^\n\r]+)', 'tech_email': r'Technical: *Name: *[^\n\r]+\s*Organisation: *[^\n\r]+\s*Language: *[^\n\r]+\s*Phone: *[^\n\r]+\s*Fax: *[^\n\r]+\s*Email: *([^\n\r]+)', 'registrar': r'Registrar: *Name: *([^\n\r]+)', - 'name_servers': r'Name servers: *([^\n\r]+)\s*([^\n\r]*)', # list of name servers + 'name_servers': r'Name servers:\s*(.+)', # list of name servers } def __init__(self, domain, text): @@ -840,7 +847,6 @@ 'status': 'registration status: s*(.+)', 'expiration_date': 'expires at: *(.+)', } - dayfirst = True def __init__(self, domain, text): @@ -1294,7 +1300,6 @@ 'registrar': 'registrar name: *(.+)', 'referral_url': 'registrar info: *(.+)', } - dayfirst = True def __init__(self, domain, text): @@ -1398,3 +1403,59 @@ raise PywhoisError(text) else: WhoisEntry.__init__(self, domain, text, self.regex) + + +class WhoisLu(WhoisEntry): + """Whois parser for .lu domains + """ + regex = { + 'domain_name': 'domainname: *(.+)', + 'creation_date': 'registered: *(.+)', + 'name_servers': 'nserver: *(.+)', + 'status': 'domaintype: *(.+)', + 'registrar': 'registrar-name: *(.+)', + 'registrant_name': 'org-name: *(.+)', + 'registrant_address': 'org-address: *(.+)', + 'registrant_postal_code': 'org-zipcode:*(.+)', + 'registrant_city': 'org-city: *(.+)', + 'registrant_country': 'org-country: *(.+)', + 'admin_name': 'adm-name: *(.+)', + 'admin_address': 'adm-address: *(.+)', + 'admin_postal_code': 'adm-zipcode: *(.+)', + 'admin_city': 'adm-city: *(.+)', + 'admin_country': 'adm-country: *(.+)', + 'admin_email': 'adm-email: *(.+)', + 'tech_name': 'tec-name: *(.+)', + 'tech_address': 'tec-address: *(.+)', + 'tech_postal_code': 'tec-zipcode: *(.+)', + 'tech_city': 'tec-city: *(.+)', + 'tech_country': 'tec-country: *(.+)', + 'tech_email': 'tec-email: *(.+)', + } + + def __init__(self, domain, text): + if 'No such domain' in text: + raise PywhoisError(text) + else: + WhoisEntry.__init__(self, domain, text, self.regex) + + +class WhoisCz(WhoisEntry): + """Whois parser for .cz domains + """ + regex = { + 'domain_name': 'domain: *(.+)', + 'registrant_name': 'registrant: *(.+)', + 'registrar': 'registrar: *(.+)', + 'creation_date': 'registered: *(.+)', + 'updated_date': 'changed: *(.+)', + 'expiration_date': 'expire: *(.+)', + 'name_servers': 'nserver: *(.+)', + } + + def __init__(self, domain, text): + if '% No entries found.' in text: + raise PywhoisError(text) + else: + WhoisEntry.__init__(self, domain, text, self.regex) + diff -r 2fb992c480e4 -r 08cfbab35d0b whois/whois.py --- a/whois/whois.py Fri Feb 16 20:12:48 2018 +0100 +++ b/whois/whois.py Tue May 22 15:10:43 2018 +0000 @@ -38,7 +38,7 @@ import sys import socket import optparse - +import os class NICClient(object): @@ -97,7 +97,17 @@ there for contact details """ response = b'' - s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + if "SOCKS" in os.environ: + try: + import socks + except ImportError as e: + print("You need to install the Python socks module. Install PIP (https://bootstrap.pypa.io/get-pip.py) and then 'pip install PySocks'") + raise e + socksproxy, port = os.environ["SOCKS"].split(":") + s = socks.socksocket() + s.set_proxy(socks.SOCKS5, socksproxy, int(port)) + else: + s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.settimeout(10) s.connect((hostname, 43))