【发布时间】:2020-09-17 13:59:42
【问题描述】:
我尝试向代理发送 python 请求,但失败了。我做错了什么?
代码如下:
import requests
url = 'https://httpbin.org/ip'
proxies = {
"http": 'http://103.250.153.242',
"https": 'http://103.250.153.242'
}
response = requests.get(url,proxies=proxies)
print(response.json())
结果应该返回 {'origin': '103.250.153.242'} 但我得到了这个:
Traceback (most recent call last):
File "C:\Python37\lib\site-packages\urllib3\connection.py", line 160, in _new_conn
(self._dns_host, self.port), self.timeout, **extra_kw)
File "C:\Python37\lib\site-packages\urllib3\util\connection.py", line 80, in create_connection
raise err
File "C:\Python37\lib\site-packages\urllib3\util\connection.py", line 70, in create_connection
sock.connect(sa)
TimeoutError: [WinError 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond
我该如何解决这个问题?
【问题讨论】:
标签: python python-requests proxies