1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
| import warnings from numpy import dsplit import tushare as ts import pandas as pd import matplotlib.pyplot as plt import os from pandas import ExcelWriter
token = os.getenv('TUSHARE_TOKEN') pro = ts.pro_api(token)
excel_header = ['股票代码', '法人代表', '总经理', '董秘', '注册资本', '注册日期', '省份', '城市', '公司介绍', '公司主页', '主营业务及产品', '员工人数', '经营范围']
datasz = pro.stock_company( exchange='SZSE', fields='ts_code,chairman,manager,secretary,reg_capital,setup_date,province,city,introduction,website,employees,main_business,business_scope') datash = pro.stock_company( exchange='SSE', fields='ts_code,chairman,manager,secretary,reg_capital,setup_date,province,city,introduction,website,employees,main_business,business_scope')
with ExcelWriter("Stock_Basic_Info.xlsx") as writer: datash.to_excel(writer, sheet_name='上交所', header=excel_header, index=False) datasz.to_excel(writer, sheet_name='深交所', header=excel_header, index=False)
|