This commit is contained in:
qsc
2025-11-11 16:47:06 +08:00
parent 2ee604d253
commit dde1d0f3ad
5 changed files with 63 additions and 19 deletions
+14
View File
@@ -113,5 +113,19 @@
"server": "眉间雪", "server": "眉间雪",
"itemIds": ["5_76650"] "itemIds": ["5_76650"]
} }
},
"wbl_waiguan":{
"url":"https://trade-api.seasunwbl.com/api/buyer/goods/list",
"method":"GET",
"description":"万宝楼官方交易数据",
"params":{
"filter[state]": "0",
"filter[role_appearance]": "浮屠明音礼盒",
"page": "1",
"size": "10",
"goods_type": "3",
"sort[price]": "1"
}
} }
} }
+1 -1
View File
@@ -127,7 +127,7 @@ class APIClient:
# 检查是否有code字段 # 检查是否有code字段
if data and 'code' in data: if data and 'code' in data:
# 有code字段时,检查是否成功 # 有code字段时,检查是否成功
if data.get('code') not in [200, "0", 0]: if data.get('code') not in [200, "0", 0, 1]:
logger.error(f"API返回错误:{data.get('code', '未知状态')} {data.get('msg', '未知错误')}") logger.error(f"API返回错误:{data.get('code', '未知状态')} {data.get('msg', '未知错误')}")
return None return None
else: else:
+26 -16
View File
@@ -359,7 +359,7 @@ class JX3Function:
return return_data return return_data
# 查询万宝楼数据(公示和在售) # 查询万宝楼数据(公示和在售)
wbl_data = await self.__get_wbl_data(searchId) wbl_data = await self.__get_wbl_data(showName)
if not wbl_data: if not wbl_data:
return_data["msg"] = "获取万宝楼数据失败" return_data["msg"] = "获取万宝楼数据失败"
return return_data return return_data
@@ -378,23 +378,24 @@ class JX3Function:
return return_data return return_data
async def __get_wbl_data(self,search_id): async def __get_wbl_data(self,showName):
"""获取万宝楼数据(公示和在售)""" """获取万宝楼数据(公示和在售)"""
try: try:
#在配置文件中获取接口配置 #在配置文件中获取接口配置
api_config = self.__api_config["aijx3_wblwg"] #api_config = self.__api_config["aijx3_wblwg"]
api_config = self.__api_config["wbl_waiguan"]
#更新参数 #更新参数
api_config["params"]["searchId"] = [search_id] api_config["params"]["filter[role_appearance]"] = showName
# 获取公示数据 # 获取公示数据
api_config["params"]["tradeStatus"] = "3" api_config["params"]["filter[state]"] = "1"
datawblgs = await self.__api.post(api_config["url"], api_config["params"], "data") datawblgs = await self.__api.get(api_config["url"], api_config["params"], "data")
# 获取在售数据 # 获取在售数据
api_config["params"]["tradeStatus"] = "5" api_config["params"]["filter[state]"] = "2"
datawblzs = await self.__api.post(api_config["url"], api_config["params"], "data") datawblzs = await self.__api.get(api_config["url"], api_config["params"], "data")
return { return {
"wblgs": await self.__process_wbl_records(datawblgs.get("records", [])), "wblgs": await self.__process_wbl_records(datawblgs.get("list", [])),
"wblzs": await self.__process_wbl_records(datawblzs.get("records", [])) "wblzs": await self.__process_wbl_records(datawblzs.get("list", []))
} }
except Exception as e: except Exception as e:
logger.error(f"获取万宝楼数据出错: {e}") logger.error(f"获取万宝楼数据出错: {e}")
@@ -407,13 +408,22 @@ class JX3Function:
for record in records: for record in records:
try: try:
# 转换时间戳为可读格式 # 转换时间戳为可读格式
timestamp = record.get("replyTime", 0) timestamp = record.get("remaining_time", 0)
dt = datetime.fromtimestamp(timestamp / 1000) if timestamp else datetime.now() days = timestamp // 86400 # 每天有 86400 秒
hours = (timestamp % 86400) // 3600 # 每小时有 3600 秒
minutes = (timestamp % 3600) // 60 # 每分钟有 60 秒
result = ""
if days > 0:
result = (f"{days}")
if hours > 0:
result += (f"{hours}")
if minutes > 0:
result += (f"{minutes}分钟")
single_unit_price = record.get("single_unit_price", 0)
processed.append({ processed.append({
"priceNum": record.get("priceNum", 0), "priceNum": "{:.2f}".format( single_unit_price / 100),
"belongQf2": record.get("belongQf2", "无数据"), "belongQf2": record.get("server_name", "无数据"),
"replyTime": dt.strftime("%Y-%m-%d %H:%M:%S"), "replyTime": result,
"discountRate": record.get("discountRate", 0.0), "discountRate": record.get("discountRate", 0.0),
}) })
except Exception as e: except Exception as e:
+20
View File
@@ -0,0 +1,20 @@
import aiohttp
import asyncio
async def fetch_data():
url = "https://trade-api.seasunwbl.com/api/buyer/goods/list?filter%255Bstate%255D=1&page=1&size=10&goods_type=3&sort%255Bprice%255D=1&filter%255Brole_appearance%255D=%25E6%25BB%2587%25E6%259E%2597%25E9%259B%25A8%25C2%25B7%25E7%259F%25A5%25E5%258D%2597%25C2%25B7%25E6%25A0%2587%25E5%2587%2586"
headers = {
'User-Agent': 'Apifox/1.0.0 (https://apifox.com)',
'Accept': '*/*',
'Host': 'trade-api.seasunwbl.com',
'Connection': 'keep-alive',
'Cookie': 'ts_session_id=AqvN1gha8NDXTjdauL6ApVT4KgbJLvPv0Dnd9uid; ts_session_id_=AqvN1gha8NDXTjdauL6ApVT4KgbJLvPv0Dnd9uid'
}
async with aiohttp.ClientSession() as session:
async with session.get(url, headers=headers) as response:
data = await response.text()
print(data)
# Run the async function
asyncio.run(fetch_data())
+2 -2
View File
@@ -149,7 +149,7 @@
<table class="table table-hover"> <table class="table table-hover">
<thead> <thead>
<tr> <tr>
<th>上架时间</th> <th>剩余时间</th>
<th>服务器</th> <th>服务器</th>
<th>价格</th> <th>价格</th>
<th>折扣率</th> <th>折扣率</th>
@@ -184,7 +184,7 @@
<table class="table table-hover"> <table class="table table-hover">
<thead> <thead>
<tr> <tr>
<th>上架时间</th> <th>剩余时间</th>
<th>服务器</th> <th>服务器</th>
<th>价格</th> <th>价格</th>
<th>折扣率</th> <th>折扣率</th>