I tried everything on this q & a to solve this problem, but I still get this error.
My last attempt is based on Lukasa's comment , and my code is as follows:
import requests from requests.adapters import HTTPAdapter from requests.packages.urllib3.poolmanager import PoolManager import ssl class MyAdapter(HTTPAdapter): def init_poolmanager(self, connections, maxsize, block=False): self.poolmanager = PoolManager(num_pools=connections, maxsize=maxsize, block=block, ssl_version=ssl.PROTOCOL_TLSv1) proxy = 'https://78.130.136.2:8080' g = 'https://www.google.com/' s = requests.Session() s.mount('https://', MyAdapter()) r = s.get(g, proxies={'https': proxy} ) print r.text.encode('utf-8')
I get the full error:
Traceback (most recent call last): File "/Users/Dionysis_Lorentzos/Projects/getter/proxy.py", line 30, in <module> r = s.get(g, proxies={'https': proxy}, verify=True ) File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/requests/sessions.py", line 347, in get return self.request('GET', url, **kwargs) File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/requests/sessions.py", line 335, in request resp = self.send(prep, **send_kwargs) File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/requests/sessions.py", line 438, in send r = adapter.send(request, **kwargs) File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/requests/adapters.py", line 331, in send raise SSLError(e) requests.exceptions.SSLError: [Errno 8] _ssl.c:504: EOF occurred in violation of protocol
So, how can I get site data with a proxy server through https ? (proxy works fine in my Firefox)
source share