diff --git a/getTodayLine.py b/getTodayLine.py index 6b02c4b..35bb9ca 100644 --- a/getTodayLine.py +++ b/getTodayLine.py @@ -43,10 +43,55 @@ db = dbConn.MY_SQL() db.save_today_table(data['data']['diff'], time.strftime("%Y-%m-%d", time.localtime())) + +def getSHSZDayLine(code): + url = 'http://28.push2his.eastmoney.com/api/qt/stock/kline/get?secid='+code+'&ut=&fields1=f1%2Cf2%2Cf3%2Cf4%2Cf5&fields2=f51%2Cf52%2Cf53%2Cf54%2Cf55%2Cf56%2Cf57%2Cf58&klt=101&fqt=0&end=20500101&lmt=10000' + conn = httpConn.HttpConnect() + res = conn.request_get(url) + print(code) + + if res == '': + print('查询dayLine失败') + + else: + data = res['data'] + lines = [] + preShouPan = 0 + for i in data['klines']: + arr = i.split(',') + # 如果是上证000001,转换一下代码,以防和平安银行[000001]冲突 + if data['code'] == '000001': + arr.append('100001') + else: + arr.append(data['code']) + arr.append(data['name']) + + if data['market'] == 0: + arr.append('1') + else: + arr.append('0') + + if preShouPan == 0: + arr.append(0) + else: + arr.append('%.3f' % ((float(arr[2]) - float(preShouPan))/float(preShouPan)*100)) + + preShouPan = float(arr[2]) + # print(arr) + + lines.append(arr) + + db = dbConn.MY_SQL() + db.save_day_line_table(lines) + + if getA000001(): s = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) startTime = time.time() getAllTodayPrice() - + + getSHSZDayLine('1.000001') + getSHSZDayLine('0.399001') + print(s + ' 当日收盘数据用时: ' + str(time.time() - startTime)) \ No newline at end of file