对于httpx的代理一直报错的情况:
发生异常: ValueError
Proxy keys should use proper URL forms rather than plain scheme strings. Instead of "http", use "http://"
发生异常: ValueError
Proxy keys should use proper URL forms rather than plain scheme strings. Instead of "http", use "http://"
这种异常是是因为httpx的proxy的代理模式和requests的不同,需要将http的键值对改为http://
如:
#第一种错误
proxy={
'http': 'http://127.0.0.1:10796' # proxy的字典键值对的需要为http://
}
这种时候只需要将键值对修改回来就可以了
#改为正确的代码
proxy={
'http://': 'http://127.0.0.1:231' # 修改键值对
}
还有报ValueError错误的:
发生异常: ValueError
Unknown scheme for proxy URL URL('127.0.0.1:10796')
发生异常: ValueError
Unknown scheme for proxy URL URL('127.0.0.1:231')
这种错误也是因为proxy的键值对的错误产生的
#键正确,值错误
proxy={
'http://': '127.0.0.1:231' #httpx的键值对的值错误
}
#完全错误
proxy={
'http': '127.0.0.1:231'
}
这种时候需要将值改为http://ip:port的形式
proxy={
'http://': 'http://127.0.0.1:231'
}
然后运行就不报错了。。