fa45d8aa5f
- health_checklist.json: 192.168.1.122→node122
- ocr_client.py: docstring IP→node122
- docs/market-data-requirements.md: IP→node122
- 所有API调用通过ProxyHandler({})绕过系统代理
Privoxy对node122:18003返回500,直连正常
36 lines
1.3 KiB
Python
36 lines
1.3 KiB
Python
import baostock as bs
|
|
import pandas as pd
|
|
|
|
#### 登陆系统 ####
|
|
lg = bs.login()
|
|
# 显示登陆返回信息
|
|
print('login respond error_code:'+lg.error_code)
|
|
print('login respond error_msg:'+lg.error_msg)
|
|
|
|
#### 查询除权除息信息####
|
|
# 查询2015年除权除息信息
|
|
rs_list = []
|
|
rs_dividend_2015 = bs.query_dividend_data(code="sh.600000", year="2015", yearType="report")
|
|
while (rs_dividend_2015.error_code == '0') & rs_dividend_2015.next():
|
|
rs_list.append(rs_dividend_2015.get_row_data())
|
|
|
|
# 查询2016年除权除息信息
|
|
rs_dividend_2016 = bs.query_dividend_data(code="sh.600000", year="2016", yearType="report")
|
|
while (rs_dividend_2016.error_code == '0') & rs_dividend_2016.next():
|
|
rs_list.append(rs_dividend_2016.get_row_data())
|
|
|
|
# 查询2017年除权除息信息
|
|
rs_dividend_2017 = bs.query_dividend_data(code="sh.600000", year="2017", yearType="report")
|
|
while (rs_dividend_2017.error_code == '0') & rs_dividend_2017.next():
|
|
rs_list.append(rs_dividend_2017.get_row_data())
|
|
|
|
result_dividend = pd.DataFrame(rs_list, columns=rs_dividend_2017.fields)
|
|
# 打印输出
|
|
print(result_dividend)
|
|
|
|
#### 结果集输出到csv文件 ####
|
|
result_dividend.to_csv("D:\\history_Dividend_data.csv", encoding="gbk",index=False)
|
|
|
|
#### 登出系统 ####
|
|
bs.logout()
|