p={
'http':'http://my correct proxy here',
'https':'https://my correct proxy here'
}
self.response=requests.get(url=url,headers=self.headers,timeout=(6,15),proxies=p)
And then it raise the exception:
Traceback (most recent call last):
File "C:\Users\xyl13509876955\Desktop\Monitor\dicks.py", line 61, in send_request
self.response=requests.get(url=url,headers=self.headers,timeout=(6,15),proxies=p)
File "C:\Users\xyl13509876955\AppData\Local\Programs\Python\Python37\lib\site-packages\requests\api.py", line 76, in get
return request('get', url, params=params, **kwargs)
File "C:\Users\xyl13509876955\AppData\Local\Programs\Python\Python37\lib\site-packages\requests\api.py", line 61, in request
return session.request(method=method, url=url, **kwargs)
File "C:\Users\xyl13509876955\AppData\Local\Programs\Python\Python37\lib\site-packages\requests\sessions.py", line 542, in request
resp = self.send(prep, **send_kwargs)
File "C:\Users\xyl13509876955\AppData\Local\Programs\Python\Python37\lib\site-packages\requests\sessions.py", line 655, in send
r = adapter.send(request, **kwargs)
File "C:\Users\xyl13509876955\AppData\Local\Programs\Python\Python37\lib\site-packages\requests\adapters.py", line 449, in send
timeout=timeout
File "C:\Users\xyl13509876955\AppData\Local\Programs\Python\Python37\lib\site-packages\urllib3\connectionpool.py", line 696, in urlopen
self._prepare_proxy(conn)
File "C:\Users\xyl13509876955\AppData\Local\Programs\Python\Python37\lib\site-packages\urllib3\connectionpool.py", line 964, in _prepare_proxy
conn.connect()
File "C:\Users\xyl13509876955\AppData\Local\Programs\Python\Python37\lib\site-packages\urllib3\connection.py", line 359, in connect
conn = self._connect_tls_proxy(hostname, conn)
File "C:\Users\xyl13509876955\AppData\Local\Programs\Python\Python37\lib\site-packages\urllib3\connection.py", line 506, in _connect_tls_proxy
ssl_context=ssl_context,
File "C:\Users\xyl13509876955\AppData\Local\Programs\Python\Python37\lib\site-packages\urllib3\util\ssl_.py", line 432, in ssl_wrap_socket
ssl_sock = _ssl_wrap_socket_impl(sock, context, tls_in_tls)
File "C:\Users\xyl13509876955\AppData\Local\Programs\Python\Python37\lib\site-packages\urllib3\util\ssl_.py", line 474, in _ssl_wrap_socket_impl
return ssl_context.wrap_socket(sock)
File "C:\Users\xyl13509876955\AppData\Local\Programs\Python\Python37\lib\ssl.py", line 423, in wrap_socket
session=session
File "C:\Users\xyl13509876955\AppData\Local\Programs\Python\Python37\lib\ssl.py", line 827, in _create
raise ValueError("check_hostname requires server_hostname")
ValueError: check_hostname requires server_hostname
Please help me solve the problem and the best way is to show me the right code. I am very confused and frustrated for the problem!!
as a work around:
pip install urllib3==1.25.11
As I understand, in new urllib3 the main schema of proxy was changed... can read here. This settings help for me (for urllib3=1.26.4).
An old
proxy={
'http':'8.88.888.8:8888',
'https':'8.88.888.8:8888'
}
The new
proxy={
'https': 'https://8.88.888.8:8888',
'http': 'http://8.88.888.8:8888',
}
UPDATED
I have met this issue again for requests 2.26.0, but in this time it works with an old schema...
proxy={
'http':'8.88.888.8:8888',
'https':'8.88.888.8:8888'
}
I have solved the problem. It is a bug with urllib3.
You can use pip install urllib3==1.25.8
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With