示例"/>
python获取网上股市信息示例
# 从网上获取股票交易历史数据
# url = '.html?code=1000001&start=19910401&end=19910409'
# url += '&fields=LCLOSE;TOPEN;HIGH;LOW;TCLOSE;CHG;PCHG;TURNOVER;VOTURNOVER;VATURNOVER;TCAP;MCAP' import requests
import pandas as pd
import matplotlib.pyplot as pltstock_code='1000020'
start_date='19990809'
end_date='20190809'url = '.html?code={}&start={}&end={}'.format(stock_code,start_date,end_date)#从网上获取数据
online_data=requests.get(url)csv_file_name='stock_{}.csv'.format(stock_code)#将数据保存到本地csv文件
with open(csv_file_name,"wb") as f:f.write(online_data.content)stock_data=pd.read_csv(csv_file_name,encoding='gb2312')stock_data=stock_data.sort_values(by = ["日期"],ascending = [True],i
更多推荐
python获取网上股市信息示例
发布评论