pip3 install -i https://pypi.tuna.tsinghua.edu.cn/simple lxml
pip3 install -i https://pypi.tuna.tsinghua.edu.cn/simple pandas
pip3 install -i https://pypi.tuna.tsinghua.edu.cn/simple tushare
pip3 bs4
python
>>import tushare as ts
>>ts.get_hist_data('600848') #一次性获取全部日k线数据
文章来源地址:http://tushare.waditu.com/index.html
新网址:https://tushare.pro/
mysql:
CREATE USER 'stock'@'%' IDENTIFIED BY 'stock';
$pip install mysql-python
$python
from sqlalchemy import create_engine
import tushare as ts
df = ts.get_tick_data('600848', date='2018-11-2')
engine = create_engine('mysql://stock:[email protected]/stock?charset=utf8')
#存入数据库
df.to_sql('tick_data',engine)
#追加数据到现有表
#df.to_sql('tick_data',engine,if_exists='append')