#-*- coding: utf-8 -*-
importrequestsfrom bs4 importBeautifulSoupimportlxmlimportjsonimportreimporttimeimporttushare as tsimportpandas as pdimportpymysqlfrom sqlalchemy importcreate_engine
pymysql.install_as_MySQLdb()defTstockbasic(conn):#调用stock_basic,获取股票代码、股票名称、所属行业、上市日期、上市场所
cursor=conn.cursor()#读取数据库已存储数据
sql_stk_data = pd.read_sql("select ts_code from stk_basic_data",con=conn).values#创建空列表,存储ts_code
code_list =[]
incount= upcount = fincount = fupcount =0
stk_basic= pro.stock_basic(list_status=L, fields= s_code,symbol,name,industry,list_date,exchange)for index, row instk_basic.iterrows():#new_code = row[ s_code][7:]+row[ s_code][:6]
new_code = row[ s_code]
stk_code= row[symbol]
stk_name= row[ ame]
industry&#