用requests的post方法获取内容时,遇到以下报错:
ConnectionError: HTTPConnectionPool(host=‘xxx.xx.xxx.xxx’, port=xxxx): Max retries exceeded with url: /api/v1/login/ (Caused by NewConnectionError(’<urllib3.connection.HTTPConnection object at 0x7f7c98a867d0>: Failed to establish a new connection: [Errno 111] Connection refused’,))
提示说请求太频繁,查阅资料有方法说用sleep,但是并没有解决我遇到的这种问题,最后解决办法是:
关闭多余的连接
s = requests.session()
s.keep_alive = False