问题
在使用akshare获取行情数据时,
import akshare as ak
stock_zh_index_daily_df = ak.stock_zh_index_daily(symbol="sz399552")
print(stock_zh_index_daily_df)
失败了,提示RemoteDisconnected
http.client.RemoteDisconnected: Remote end closed connection without response
解决方案
首先在网络上搜索了一些方法,如更新akshare库、检查代理、更换网络、手动登录东财网站等,均无效,请优先检查以上问题,如果都无效,再往下看。
有效方案
最终在github上看到一个项目,按照其操作,仅两三句命令就解决了该问题(感谢作者): https://github.com/helloYie/akshare-proxy-patch
具体操作如下:
pip install akshare-proxy-patch==0.2.8
# 新增
import akshare_proxy_patch
akshare_proxy_patch.install_patch("101.201.173.125", "", 50)
# 原始获取行情代码
import akshare as ak
stock_zh_index_daily_df = ak.stock_zh_index_daily(symbol="sz399552")
print(stock_zh_index_daily_df)





