Guide
error
when r = requests.get(url)
, error occur:
requests.exceptions.ProxyError: HTTPConnectionPool(host=’127.0.0.1’, port=8888):
Max retries exceeded with url: http://www.baidu.com/ (Caused by ProxyError(‘Cannot
connect to proxy.’, NewConnectionError(‘<urllib3.connection.HTTPConnection object
at 0x7f5611990080>: Failed to establish a new connection: [Errno 111] Connection
refused’)))
solutions
$ env | grep -i proxy
export http_proxy='127.0.0.1:8888'
export https_proxy='127.0.0.1:8888'
export ftp_proxy=''
export socks_proxy=''
edit ~/.bashrc
export http_proxy=''
export https_proxy=''
export ftp_proxy=''
export socks_proxy=''
and run source ~.bashrc
Now OK.
or by code
proxies = { "http": None, "https": None}
requests.get("http://baidu.com", proxies=proxies)
Reference
History
- 2019/11/08: created.