This commit is contained in:
27942
2025-10-20 15:26:23 +08:00
parent f9a0b8f487
commit 0e7b3669f9
4 changed files with 98 additions and 3 deletions

View File

@@ -0,0 +1,83 @@
import time
from curl_cffi import requests
from models.weex import Weex1Hour
headers = {
'accept': 'application/json, text/plain, */*',
'accept-language': 'zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6',
'appversion': '2.0.0',
'bundleid': '',
'cache-control': 'no-cache',
'dnt': '1',
'language': 'zh_CN',
'origin': 'https://www.weeaxs.site',
'pragma': 'no-cache',
'priority': 'u=1, i',
'referer': 'https://www.weeaxs.site/',
'sec-ch-ua': '"Chromium";v="140", "Not=A?Brand";v="24", "Microsoft Edge";v="140"',
'sec-ch-ua-mobile': '?0',
'sec-ch-ua-platform': '"Windows"',
'sec-fetch-dest': 'empty',
'sec-fetch-mode': 'cors',
'sec-fetch-site': 'cross-site',
'sidecar': '01bfdfef90d2d6213c86b09f3a00d696d366752996a0b6692a33969a67fcd243df',
'terminalcode': '89adf61538715df59eb4f6414981484e',
'terminaltype': '1',
'traceid': 'mgoh8eoehxp15lxnbv',
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/140.0.0.0 Safari/537.36 Edg/140.0.0.0',
'vs': 'G5h7sX78yNSykC9xtTmA7O2lSKqAk6Sp',
'x-sig': '74ec6a65f3886f24a8b062e3b41edb1a',
'x-timestamp': '1760320261454',
}
klineId = None
klineTime = None
contractId = None
while True:
for i in range(10):
print(i)
params = {
'languageType': '1',
'sign': 'SIGN',
'timeZone': 'string',
'contractId': '10000002',
'productCode': 'ethusdt',
'priceType': 'LAST_PRICE',
'klineType': 'HOUR_1',
'limit': '570',
}
if klineId:
params['nextKey.klineId'] = klineId
params['nextKey.contractId'] = contractId
if klineTime:
params['nextKey.klineTime'] = klineTime
response = requests.get('https://http-gateway1.janapw.com/api/v1/public/quote/v1/getKlineV2', params=params,
headers=headers)
klineId = response.json()["data"]["nextKey"]["klineId"]
klineTime = response.json()["data"]["nextKey"]["klineTime"]
contractId = response.json()["data"]["nextKey"]["contractId"]
for data in response.json()["data"]["dataList"]:
# print(data)
Weex1Hour.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)

View File

@@ -1,7 +1,7 @@
from DrissionPage import ChromiumPage, ChromiumOptions
from bit_tools import openBrowser
from models.weex import Weex1
from models.weex import Weex1, Weex1Hour
if __name__ == '__main__':
@@ -17,7 +17,7 @@ if __name__ == '__main__':
page.set.window.max()
page.listen.start("http-gateway1.janapw.com/api/v1/public/quote/v1/getKlineV2")
page.listen.start("https://http-gateway1.janapw.com/api/v1/public/quote/v1/getKlineV2")
page.get(url="https://www.weeaxs.site/zh-CN/futures/ETH-USDT")
@@ -28,7 +28,7 @@ if __name__ == '__main__':
print(res.response.url)
for data in res.response.body['data']["dataList"]:
Weex1.get_or_create(
Weex1Hour.get_or_create(
id=int(data[4]),
defaults={
'open': float(data[3]),