Requests使用代理时出错,网上搜索了一下,原来是代理IP地址前面要加http://
正确代码:
import requests
proxy = {
'http':'http://114.228.73.217:6666'
}
url = 'http://www.httpbin.org/ip'
resp = requests.get(url,proxies=proxy)
print(resp.text)
学习:https://edu.csdn.net/course/play/24756/280668?utm_source=blogtoedu
下面是报错代码
import requests
proxy = {
'http':'114.228.73.217:6666'
}
url = 'http://www.httpbin.org/ip'
resp = requests.get(url,proxies=proxy)
print(resp.text)
Traceback (most recent call last):
File "D:/pythonunit/urllib使用/Requests_代理实例.py", line 7, in <module>
resp = requests.get(url,proxies=proxy)
File "D:\pyth