# coding=utf-8
import requests
import json
def getList(time):
head = {
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9',
'Host': 'webstock.quote.hermes.hexun.com',
'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.75 Safari/537.36'
}
url = 'http://webstock.quote.hermes.hexun.com/a/deal?code=szse000651&start=%s&number=1000,LastClose' % time
s1 = requests.get(url=url, headers = head)
r1 = (s1.text.replace('(','').replace(');', ''))
return json.loads(r1, encoding='utf-8')['Data'][0]
aT = 0
sT = 0
t = '20201208092400'
js1 = []
flag = True
while flag:
js = getList(t)
if len(js) == 1000:
t = str(js[999][0])
else:
flag = False
js1.extend(js)
print(len(js1))
for i in js1:
if i[4] == 1: # 减
sT += i[3]
elif i[4] == 2 : # 加
aT += i[3]
print(aT)
print(sT)