From dde1d0f3ad98bf9d36b6f35bd5a171c04cd6a9b7 Mon Sep 17 00:00:00 2001 From: qsc Date: Tue, 11 Nov 2025 16:47:06 +0800 Subject: [PATCH] 11 --- api_config.json | 14 ++++++++++++++ core/class_reqsest.py | 2 +- core/cless_jx3.py | 42 ++++++++++++++++++++++++++---------------- core/test.py | 20 ++++++++++++++++++++ templates/wujia.html | 4 ++-- 5 files changed, 63 insertions(+), 19 deletions(-) create mode 100644 core/test.py diff --git a/api_config.json b/api_config.json index 8c810d0..f9cdd60 100644 --- a/api_config.json +++ b/api_config.json @@ -113,5 +113,19 @@ "server": "眉间雪", "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" + } } + } \ No newline at end of file diff --git a/core/class_reqsest.py b/core/class_reqsest.py index b997f3b..628fd77 100644 --- a/core/class_reqsest.py +++ b/core/class_reqsest.py @@ -127,7 +127,7 @@ class APIClient: # 检查是否有code字段 if data and 'code' in data: # 有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', '未知错误')}") return None else: diff --git a/core/cless_jx3.py b/core/cless_jx3.py index 75d946d..2c1769a 100644 --- a/core/cless_jx3.py +++ b/core/cless_jx3.py @@ -359,7 +359,7 @@ class JX3Function: return return_data # 查询万宝楼数据(公示和在售) - wbl_data = await self.__get_wbl_data(searchId) + wbl_data = await self.__get_wbl_data(showName) if not wbl_data: return_data["msg"] = "获取万宝楼数据失败" return return_data @@ -378,23 +378,24 @@ class JX3Function: return return_data - async def __get_wbl_data(self,search_id): + async def __get_wbl_data(self,showName): """获取万宝楼数据(公示和在售)""" 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" - datawblgs = await self.__api.post(api_config["url"], api_config["params"], "data") + api_config["params"]["filter[state]"] = "1" + datawblgs = await self.__api.get(api_config["url"], api_config["params"], "data") # 获取在售数据 - api_config["params"]["tradeStatus"] = "5" - datawblzs = await self.__api.post(api_config["url"], api_config["params"], "data") + api_config["params"]["filter[state]"] = "2" + datawblzs = await self.__api.get(api_config["url"], api_config["params"], "data") return { - "wblgs": await self.__process_wbl_records(datawblgs.get("records", [])), - "wblzs": await self.__process_wbl_records(datawblzs.get("records", [])) + "wblgs": await self.__process_wbl_records(datawblgs.get("list", [])), + "wblzs": await self.__process_wbl_records(datawblzs.get("list", [])) } except Exception as e: logger.error(f"获取万宝楼数据出错: {e}") @@ -407,13 +408,22 @@ class JX3Function: for record in records: try: # 转换时间戳为可读格式 - timestamp = record.get("replyTime", 0) - dt = datetime.fromtimestamp(timestamp / 1000) if timestamp else datetime.now() - + timestamp = record.get("remaining_time", 0) + 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({ - "priceNum": record.get("priceNum", 0), - "belongQf2": record.get("belongQf2", "无数据"), - "replyTime": dt.strftime("%Y-%m-%d %H:%M:%S"), + "priceNum": "{:.2f}".format( single_unit_price / 100), + "belongQf2": record.get("server_name", "无数据"), + "replyTime": result, "discountRate": record.get("discountRate", 0.0), }) except Exception as e: diff --git a/core/test.py b/core/test.py new file mode 100644 index 0000000..08b3839 --- /dev/null +++ b/core/test.py @@ -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()) diff --git a/templates/wujia.html b/templates/wujia.html index 620ce71..5a4a817 100644 --- a/templates/wujia.html +++ b/templates/wujia.html @@ -149,7 +149,7 @@ - + @@ -184,7 +184,7 @@
上架时间剩余时间 服务器 价格 折扣率
- +
上架时间剩余时间 服务器 价格 折扣率