dededdew
This commit is contained in:
72
weex/抓取数据.py
72
weex/抓取数据.py
@@ -36,44 +36,48 @@ klineId = None
|
||||
klineTime = None
|
||||
contractId = None
|
||||
|
||||
for i in range(50):
|
||||
print(i)
|
||||
params = {
|
||||
'languageType': '1',
|
||||
'sign': 'SIGN',
|
||||
'timeZone': 'string',
|
||||
'contractId': '10000002',
|
||||
'productCode': 'ethusdt',
|
||||
'priceType': 'LAST_PRICE',
|
||||
'klineType': 'MINUTE_15',
|
||||
'limit': '329',
|
||||
}
|
||||
while True:
|
||||
|
||||
if klineId:
|
||||
params['nextKey.klineId'] = klineId
|
||||
params['nextKey.contractId'] = contractId
|
||||
for i in range(10):
|
||||
print(i)
|
||||
params = {
|
||||
'languageType': '1',
|
||||
'sign': 'SIGN',
|
||||
'timeZone': 'string',
|
||||
'contractId': '10000002',
|
||||
'productCode': 'ethusdt',
|
||||
'priceType': 'LAST_PRICE',
|
||||
'klineType': 'MINUTE_15',
|
||||
'limit': '329',
|
||||
}
|
||||
|
||||
if klineTime:
|
||||
params['nextKey.klineTime'] = klineTime
|
||||
if klineId:
|
||||
params['nextKey.klineId'] = klineId
|
||||
params['nextKey.contractId'] = contractId
|
||||
|
||||
response = requests.get('https://http-gateway1.janapw.com/api/v1/public/quote/v1/getKlineV2', params=params,
|
||||
headers=headers)
|
||||
if klineTime:
|
||||
params['nextKey.klineTime'] = klineTime
|
||||
|
||||
klineId = response.json()["data"]["nextKey"]["klineId"]
|
||||
klineTime = response.json()["data"]["nextKey"]["klineTime"]
|
||||
contractId = response.json()["data"]["nextKey"]["contractId"]
|
||||
response = requests.get('https://http-gateway1.janapw.com/api/v1/public/quote/v1/getKlineV2', params=params,
|
||||
headers=headers)
|
||||
|
||||
for data in response.json()["data"]["dataList"]:
|
||||
# print(data)
|
||||
klineId = response.json()["data"]["nextKey"]["klineId"]
|
||||
klineTime = response.json()["data"]["nextKey"]["klineTime"]
|
||||
contractId = response.json()["data"]["nextKey"]["contractId"]
|
||||
|
||||
Weex.get_or_create(
|
||||
id=int(data[4]),
|
||||
defaults={
|
||||
'open': float(data[3]),
|
||||
'high': float(data[1]),
|
||||
'low': float(data[2]),
|
||||
'close': float(data[0]),
|
||||
}
|
||||
)
|
||||
for data in response.json()["data"]["dataList"]:
|
||||
# print(data)
|
||||
|
||||
# time.sleep(1)
|
||||
Weex.get_or_create(
|
||||
id=int(data[4]),
|
||||
defaults={
|
||||
'open': float(data[3]),
|
||||
'high': float(data[1]),
|
||||
'low': float(data[2]),
|
||||
'close': float(data[0]),
|
||||
}
|
||||
)
|
||||
|
||||
# time.sleep(1)
|
||||
|
||||
time.sleep(3600)
|
||||
|
||||
Reference in New Issue
Block a user