本文以行健宏扬中国为例,提取数据,使用ARIMA算法进行时间序列预测。
爬取数据
# 抓取行健宏扬中国基金 from bs4 import BeautifulSoup import requests headers = {'Accept':'text/javascript, application/javascript, */*; q=0.01', 'Accept-Encoding':'gzip, deflate', 'Accept-Language':'zh-CN,zh;q=0.8', 'Connection':'keep-alive', 'Cookie':'vjuids=148cf0186.15e03abf2ac.0.c311af0ddaa6c; ADVS=358187b0bd1a65; ASL=17431,000pn,7010519170105191; jrj_uid=15060593555978DJcIwmvnb; jrj_z3_newsid=723; ADVC=35686f6caeedf3; WT_FPC=id=2ef30c6a0af7eaf3a501506059355507:lv=1506063782501:ss=1506063782501; channelCode=3763BEXX; ylbcode=24S2AZ96; vjlast=1503300154.1506059356.23; Hm_lvt_a07bde197b7bf109a325eebaee445939=1506059356; Hm_lpvt_a07bde197b7bf109a325eebaee445939=1506063783', 'Host':'fund.jrj.com.cn', 'Referer':'http://fund.jrj.com.cn/archives,968006,jjjz.shtml', 'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.90 Safari/537.36', 'X-Requested-With':'XMLHttpRequest'} params = {'fundCode':'968006', 'obj':'obj', 'date':2017} r = requests.get('http://fund.jrj.com.cn/json/archives/history/netvalue?',params=params,headers=headers) r.encoding ='utf-8' mydata = r.text |
存储数据