1: 安装python: https://www.cnblogs.com/liyafei/articles/11550979.html
将python.exe加入 全局path
2: 安装库:(不需要了,使用baostock代替了)
3:提示错误:C:MyFileSoftWarepythonpython.exe: No module named pip, ModuleNotFoundError: No module named
'pip' https://blog.csdn.net/haihonga/article/details/100168691
4: 安装BAOSTOCK
https://bbs.pinggu.org/thread-6387812-1-1.html
http://baostock.com/baostock/index.php/A%E8%82%A1K%E7%BA%BF%E6%95%B0%E6%8D%AE
5:代码:
import baostock as bs import pandas as pd # 登陆系统 lg = bs.login(user_id="anonymous", password="123456") # 显示登陆返回信息print('login respond error_code:'+lg.error_code) # print('login respond error_msg:'+lg.error_msg) # 查询季频估值指标盈利能力,获取2010年第二季度的数据 profit_list = [] rs_profit = bs.query_profit_data(code="sh.600000", year=2015, quarter=2) while (rs_profit.error_code == '0') & rs_profit.next(): profit_list.append(rs_profit.get_row_data()) result_profit = pd.DataFrame(profit_list, columns=rs_profit.fields) # 打印输出 print(result_profit) # 结果集输出到csv文件 # result_profit.to_csv( "C:Usersi505385DesktopHansen.csv", index=False ) # 登出系统 bs.logout()
结果:
完成。