天天看点

python使用IP代理示例及出错解决方法

一、代码示例

二、通过修改proxy_ip参数的代理IP服务器地址,可以更改代理IP

三、报错提示

requests.exceptions.ProxyError: HTTPSConnectionPool(host='www.baidu.com', port=443): Max retries exceeded with url: / (Caused by ProxyError('Cannot connect to proxy.', error(10054, '')))

出错的原因一般有2个:

1、ip代理服务器不能正常使用

如果是http代理服器的话,则如下写:

如果是https代理服务器的话,则如下写法:

本文转自 老鹰a  51CTO博客,原文链接:http://blog.51cto.com/laoyinga/2046692