chore: 去掉脚本 BOM;登录校验复用统一客户端;login.bat 不再强依赖环境变量

This commit is contained in:
houhuan committed 2026-11-16 12:54:30 +08:00
1 parent 92bd4e1b59
commit 73462d94a0
4 files changed
+19 -34

No files matched your search

+14 -23
View File
@@ -70,29 +70,20 @@ def login_with_browser(login_url: str) -> dict[str, str] | None:
return cookies
def verify(cookies: dict[str, str]) -> bool:
def verify(cfg, cookies: dict[str, str]) -> bool:
"""本地先验一次,避免把坏 Cookie 推上去。"""
import requests as _rq
resp = _rq.post(
"https://fs.szfx.com/saasmerchant/pcweb/order/quickpayorder/list",
json={"shopId": "20434543575189", "page": 1, "pageSize": 1},
headers={
"Content-Type": "application/json",
"Referer": MMS_BASE,
"Origin": "https://fs.szfx.com",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64)",
},
cookies=cookies,
timeout=20,
)
data = resp.json()
if data.get("errno") == 0:
orders = (data.get("data") or {}).get("list") or []
latest = orders[0].get("orderId") if orders else None
print(f" Cookie 校验通过(最新订单 {latest})")
return True
print(f" Cookie 校验失败:errno={data.get('errno')} {data.get('errmsg')}", file=sys.stderr)
return False
from fengxiang.client import FengxiangClient, FengxiangError
client = FengxiangClient(cfg)
client.set_cookies(cookies)
try:
orders = client.list_orders(page_size=1)
except FengxiangError as exc:
print(f" Cookie 校验失败:{exc}", file=sys.stderr)
return False
latest = orders[0].get("orderId") if orders else None
print(f" Cookie 校验通过(最新订单 {latest})")
return True
def upload(server: str, token: str, cookies: dict[str, str]) -> bool:
@@ -122,7 +113,7 @@ def main() -> int:
if not cookies:
return 1
if not verify(cookies):
if not verify(cfg, cookies):
print("Cookie 不可用,未保存。", file=sys.stderr)
return 2