dededdew
This commit is contained in:
2
logs/app.log
Normal file
2
logs/app.log
Normal file
@@ -0,0 +1,2 @@
|
||||
2025-10-22 17:25:17 [INFO] jegferwgrewgerwg | module=__main__ | function=<module>
|
||||
2025-10-22 17:25:33 [INFO] jegferwgrewgerwg | module=__main__ | function=<module>
|
||||
Binary file not shown.
45
test.py
45
test.py
@@ -1,38 +1,9 @@
|
||||
import requests
|
||||
from logly import *
|
||||
|
||||
headers = {
|
||||
'Accept': '*/*',
|
||||
'Accept-Language': 'zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6',
|
||||
'Authorization': 'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJkYXRhIjp7InVpZCI6IjY0MzNiMDMyNTBmYTQ5YTI1ZWNlYmQzMCIsInZlcnNpb24iOjAsImJyYW5jaCI6InpoIiwicGhvbmUiOiIxNzE2ODM2MDQwOCJ9LCJpYXQiOjE3NjExMDMyNzcsImV4cCI6MTc2MTI3NjA3N30.k_R1gSUW9XpE6uRiCdHrEA8MXGjGpGoWVTrhSGz-0Cc',
|
||||
'Cache-Control': 'no-cache',
|
||||
'Connection': 'keep-alive',
|
||||
'DNT': '1',
|
||||
'Pragma': 'no-cache',
|
||||
'Sec-Fetch-Dest': 'empty',
|
||||
'Sec-Fetch-Mode': 'cors',
|
||||
'Sec-Fetch-Site': 'none',
|
||||
'Sec-Fetch-Storage-Access': 'active',
|
||||
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.0.0 Safari/537.36 Edg/141.0.0.0',
|
||||
'i-app': 'hitab',
|
||||
'i-branch': 'zh',
|
||||
'i-lang': 'zh-CN',
|
||||
'i-platform': 'edge',
|
||||
'i-version': '2.2.16',
|
||||
'sec-ch-ua': '"Microsoft Edge";v="141", "Not?A_Brand";v="8", "Chromium";v="141"',
|
||||
'sec-ch-ua-mobile': '?0',
|
||||
'sec-ch-ua-platform': '"Windows"',
|
||||
}
|
||||
|
||||
response = requests.get('https://api.wetab.link/api/chat-v3/chat/history', headers=headers)
|
||||
|
||||
for i in response.json()["data"]['list']:
|
||||
print(i)
|
||||
|
||||
json_data = {
|
||||
'clId': i["id"],
|
||||
'source': 'chat',
|
||||
}
|
||||
|
||||
response = requests.post('https://api.wetab.link/api/chat-v3/conversation/delete', headers=headers, json=json_data)
|
||||
|
||||
print(response.json())
|
||||
logger.add(
|
||||
"logs/app.log",
|
||||
rotation="daily", # 或 "hourly", "10MB"
|
||||
retention=7,
|
||||
async_write=True # 启用异步写入,不阻塞主线程
|
||||
)
|
||||
logger.success("jegferwgrewgerwg")
|
||||
|
||||
@@ -1,45 +1,173 @@
|
||||
from DrissionPage import ChromiumPage, ChromiumOptions
|
||||
import json
|
||||
|
||||
import requests
|
||||
|
||||
from loguru import *
|
||||
from DrissionPage import *
|
||||
|
||||
from models.weex import *
|
||||
|
||||
|
||||
def is_bullish(c): # 阳线
|
||||
return float(c['close']) > float(c['open'])
|
||||
|
||||
|
||||
def is_bearish(c): # 阴线
|
||||
return float(c['close']) < float(c['open'])
|
||||
|
||||
|
||||
class WeexTransaction:
|
||||
def __init__(self, bit_id):
|
||||
self.bit_port = None # 比特浏览器使用端口
|
||||
self.bit_id = bit_id # 比特id
|
||||
self.bit_url = "http://127.0.0.1:54345" # 比特本地服务url
|
||||
self.bit_headers = {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
|
||||
self.page = None # 浏览器对象
|
||||
|
||||
self.start = None # 持仓状态
|
||||
|
||||
def openBrowser(self, ): # 直接指定ID打开窗口,也可以使用 createBrowser 方法返回的ID
|
||||
|
||||
json_data = {
|
||||
"id": f'{self.bit_id}',
|
||||
}
|
||||
|
||||
try:
|
||||
|
||||
res = requests.post(
|
||||
url=f"{self.bit_url}/browser/open",
|
||||
data=json.dumps(json_data),
|
||||
headers=self.bit_headers
|
||||
).json()
|
||||
|
||||
self.bit_port = res["data"]["http"].split(":")[1]
|
||||
|
||||
return True
|
||||
except:
|
||||
return False
|
||||
|
||||
def take_over_browser(self):
|
||||
try:
|
||||
co = ChromiumOptions()
|
||||
co.set_local_port(self.bit_port)
|
||||
|
||||
self.page = ChromiumPage(addr_or_opts=co)
|
||||
|
||||
self.page.set.window.max()
|
||||
|
||||
self.page.get(url="https://www.weeaxs.site/zh-CN/futures/demo-trading/ETH-SUSDT")
|
||||
|
||||
return True
|
||||
except:
|
||||
return False
|
||||
|
||||
def is_bullish(self, c): # 阳线
|
||||
return float(c['close']) > float(c['open'])
|
||||
|
||||
def is_bearish(self, c): # 阴线
|
||||
return float(c['close']) < float(c['open'])
|
||||
|
||||
def get_price(self):
|
||||
|
||||
for i in range(3):
|
||||
try:
|
||||
logger.info(f"获取最新数据:{i + 1}次。。。")
|
||||
self.page.refresh()
|
||||
res = self.page.listen.wait(timeout=15) # 等待并获取一个数据包
|
||||
|
||||
datas = []
|
||||
if res:
|
||||
for data in res.response.body['data']["dataList"]:
|
||||
insert_data = {
|
||||
'id': int(data[4]),
|
||||
'open': float(data[3]),
|
||||
'high': float(data[1]),
|
||||
'low': float(data[2]),
|
||||
'close': float(data[0])
|
||||
}
|
||||
|
||||
datas.append(insert_data)
|
||||
|
||||
return datas
|
||||
except:
|
||||
pass
|
||||
|
||||
return False
|
||||
|
||||
def action(self):
|
||||
|
||||
# 获取比特端口
|
||||
if self.openBrowser():
|
||||
logger.info("获取打开比特成功,成功获取端口!!!")
|
||||
else:
|
||||
logger.error("打开比特失败!!!")
|
||||
return
|
||||
|
||||
# 接管浏览器
|
||||
if self.take_over_browser():
|
||||
logger.info("接管比特浏览器成功!!!")
|
||||
else:
|
||||
logger.error("接管浏览器失败!!!")
|
||||
return
|
||||
|
||||
self.page.listen.start("public/quote/v1/getKlineV2")
|
||||
logger.success("浏览器开启抓包模式。。。")
|
||||
|
||||
new_price_datas = self.get_price()
|
||||
if new_price_datas:
|
||||
logger.success("获取最新交易价格成功!!!")
|
||||
else:
|
||||
logger.info("获取最新价格有问题!!!")
|
||||
|
||||
new_price_datas1 = sorted(new_price_datas, key=lambda x: x["id"])
|
||||
prev, curr, next_bar = new_price_datas1[-3:]
|
||||
|
||||
pass
|
||||
|
||||
from bit_tools import openBrowser
|
||||
from models.weex import Weex30Copy
|
||||
|
||||
if __name__ == '__main__':
|
||||
WeexTransaction(
|
||||
bit_id="8dcb4f744cf64ab190e465e153088515"
|
||||
).action()
|
||||
|
||||
bit_port = openBrowser(id="8dcb4f744cf64ab190e465e153088515")
|
||||
# bit_port = openBrowser(id="8dcb4f744cf64ab190e465e153088515")
|
||||
|
||||
co = ChromiumOptions()
|
||||
co.set_local_port(port=bit_port)
|
||||
# co = ChromiumOptions()
|
||||
# co.set_local_port(port=bit_port)
|
||||
#
|
||||
# co = ChromiumOptions()
|
||||
# co.set_local_port(bit_port)
|
||||
#
|
||||
# page = ChromiumPage(addr_or_opts=co)
|
||||
#
|
||||
# page.set.window.max()
|
||||
|
||||
co = ChromiumOptions()
|
||||
co.set_local_port(bit_port)
|
||||
|
||||
page = ChromiumPage(addr_or_opts=co)
|
||||
|
||||
page.set.window.max()
|
||||
|
||||
page.listen.start("public/quote/v1/getKlineV2")
|
||||
|
||||
page.get(url="https://www.weeaxs.site/zh-CN/futures/demo-trading/ETH-SUSDT")
|
||||
|
||||
for _ in range(10000):
|
||||
res = page.listen.wait() # 等待并获取一个数据包
|
||||
|
||||
print(_)
|
||||
print(res.response.url)
|
||||
|
||||
for data in res.response.body['data']["dataList"]:
|
||||
# 构建插入数据的字典
|
||||
insert_data = {
|
||||
'id': int(data[4]),
|
||||
'open': float(data[3]),
|
||||
'high': float(data[1]),
|
||||
'low': float(data[2]),
|
||||
'close': float(data[0])
|
||||
}
|
||||
|
||||
# 使用 INSERT OR REPLACE 插入或更新数据
|
||||
query = Weex30Copy.insert(**insert_data).on_conflict(
|
||||
conflict_target=[Weex30Copy.id],
|
||||
update=insert_data
|
||||
)
|
||||
query.execute()
|
||||
# page.listen.start("public/quote/v1/getKlineV2")
|
||||
#
|
||||
# page.get(url="https://www.weeaxs.site/zh-CN/futures/demo-trading/ETH-SUSDT")
|
||||
#
|
||||
# for _ in range(10000):
|
||||
# res = page.listen.wait() # 等待并获取一个数据包
|
||||
#
|
||||
# print(_)
|
||||
# print(res.response.url)
|
||||
#
|
||||
# for data in res.response.body['data']["dataList"]:
|
||||
# # 构建插入数据的字典
|
||||
# insert_data = {
|
||||
# 'id': int(data[4]),
|
||||
# 'open': float(data[3]),
|
||||
# 'high': float(data[1]),
|
||||
# 'low': float(data[2]),
|
||||
# 'close': float(data[0])
|
||||
# }
|
||||
#
|
||||
# # 使用 INSERT OR REPLACE 插入或更新数据
|
||||
# query = Weex30Copy.insert(**insert_data).on_conflict(
|
||||
# conflict_target=[Weex30Copy.id],
|
||||
# update=insert_data
|
||||
# )
|
||||
# query.execute()
|
||||
|
||||
Reference in New Issue
Block a user