使用Crawlera的示例代码处理带有代理的GET请求。在
import requests
url = "http://httpbin.org/ip"
proxy_host = "proxy.crawlera.com"
proxy_port = "8010"
proxy_auth = "<APIKEY>:" # Make sure to include ':' at the end
proxies = {
"https": "https://{}@{}:{}/".format(proxy_auth, proxy_host, proxy_port),
"http": "http://{}@{}:{}/".format(proxy_auth, proxy_host, proxy_port)
}
r = requests.get(url, proxies=proxies, verify=False)
我收到一个407错误的代理验证错误。我已经检查了三倍,看看API密钥是否正确。在
响应标头:
^{pr2}$请求已更新。在
$ pip freeze |grep requests
requests==2.8.1
我通过添加一个
Proxy-Authorization
头成功地让它工作起来。在如果希望保留“crawlera”方式,可以尝试升级请求客户端:
我也遇到了同样的问题,你的解决方案奏效了,但在进一步搜索之后,我找到了this解决方案:
正在升级到
requests
客户端到2.19。。。对我有用,我可以继续使用crawlara示例脚本。在相关问题 更多 >
编程相关推荐