JavaScript
x
6
1
p={
2
'http':'http://my correct proxy here',
3
'https':'https://my correct proxy here'
4
}
5
self.response=requests.get(url=url,headers=self.headers,timeout=(6,15),proxies=p)
6
And then it raise the exception:
JavaScript
1
31
31
1
Traceback (most recent call last):
2
File "C:Usersxyl13509876955DesktopMonitordicks.py", line 61, in send_request
3
self.response=requests.get(url=url,headers=self.headers,timeout=(6,15),proxies=p)
4
File "C:Usersxyl13509876955AppDataLocalProgramsPythonPython37libsite-packagesrequestsapi.py", line 76, in get
5
return request('get', url, params=params, **kwargs)
6
File "C:Usersxyl13509876955AppDataLocalProgramsPythonPython37libsite-packagesrequestsapi.py", line 61, in request
7
return session.request(method=method, url=url, **kwargs)
8
File "C:Usersxyl13509876955AppDataLocalProgramsPythonPython37libsite-packagesrequestssessions.py", line 542, in request
9
resp = self.send(prep, **send_kwargs)
10
File "C:Usersxyl13509876955AppDataLocalProgramsPythonPython37libsite-packagesrequestssessions.py", line 655, in send
11
r = adapter.send(request, **kwargs)
12
File "C:Usersxyl13509876955AppDataLocalProgramsPythonPython37libsite-packagesrequestsadapters.py", line 449, in send
13
timeout=timeout
14
File "C:Usersxyl13509876955AppDataLocalProgramsPythonPython37libsite-packagesurllib3connectionpool.py", line 696, in urlopen
15
self._prepare_proxy(conn)
16
File "C:Usersxyl13509876955AppDataLocalProgramsPythonPython37libsite-packagesurllib3connectionpool.py", line 964, in _prepare_proxy
17
conn.connect()
18
File "C:Usersxyl13509876955AppDataLocalProgramsPythonPython37libsite-packagesurllib3connection.py", line 359, in connect
19
conn = self._connect_tls_proxy(hostname, conn)
20
File "C:Usersxyl13509876955AppDataLocalProgramsPythonPython37libsite-packagesurllib3connection.py", line 506, in _connect_tls_proxy
21
ssl_context=ssl_context,
22
File "C:Usersxyl13509876955AppDataLocalProgramsPythonPython37libsite-packagesurllib3utilssl_.py", line 432, in ssl_wrap_socket
23
ssl_sock = _ssl_wrap_socket_impl(sock, context, tls_in_tls)
24
File "C:Usersxyl13509876955AppDataLocalProgramsPythonPython37libsite-packagesurllib3utilssl_.py", line 474, in _ssl_wrap_socket_impl
25
return ssl_context.wrap_socket(sock)
26
File "C:Usersxyl13509876955AppDataLocalProgramsPythonPython37libssl.py", line 423, in wrap_socket
27
session=session
28
File "C:Usersxyl13509876955AppDataLocalProgramsPythonPython37libssl.py", line 827, in _create
29
raise ValueError("check_hostname requires server_hostname")
30
ValueError: check_hostname requires server_hostname
31
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!!
Advertisement
Answer
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
JavaScript
1
5
1
proxy={
2
'http':'8.88.888.8:8888',
3
'https':'8.88.888.8:8888'
4
}
5
The new
JavaScript
1
5
1
proxy={
2
'https': 'https://8.88.888.8:8888',
3
'http': 'http://8.88.888.8:8888',
4
}
5
UPDATED
I have met this issue again for requests 2.26.0, but in this time it works with an old schema…
JavaScript
1
5
1
proxy={
2
'http':'8.88.888.8:8888',
3
'https':'8.88.888.8:8888'
4
}
5