Initial commit: Fengxiang order monitor with WeChat & Xiaomi speaker push
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
"""
|
||||
丰享商家端数据抓取 - Cookie 复用模式
|
||||
已有 cookies.json 时直接调用接口,Cookie 过期再运行主脚本重新登录
|
||||
"""
|
||||
|
||||
import json
|
||||
import sys
|
||||
import requests
|
||||
|
||||
DATA_API = "https://fs.szfx.com/saasmerchant/pcweb/order/quickpayorder/list"
|
||||
SHOP_ID = "20434543575189"
|
||||
|
||||
|
||||
def load_cookies():
|
||||
try:
|
||||
with open("cookies.json", "r", encoding="utf-8") as f:
|
||||
return json.load(f)
|
||||
except FileNotFoundError:
|
||||
print("未找到 cookies.json,请先运行 fengxiang_scraper.py 完成登录")
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
def fetch_order_list(cookies, page=1, page_size=20):
|
||||
headers = {
|
||||
"Content-Type": "application/json",
|
||||
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36",
|
||||
"Referer": "https://fs.szfx.com/MMS",
|
||||
"Origin": "https://fs.szfx.com",
|
||||
}
|
||||
payload = {"shopId": SHOP_ID, "page": page, "pageSize": page_size}
|
||||
resp = requests.post(DATA_API, json=payload, headers=headers, cookies=cookies, timeout=30)
|
||||
return resp.json()
|
||||
|
||||
|
||||
def main():
|
||||
cookies = load_cookies()
|
||||
print(f"已加载 {len(cookies)} 个 Cookie")
|
||||
|
||||
page = int(sys.argv[1]) if len(sys.argv) > 1 else 1
|
||||
result = fetch_order_list(cookies, page=page)
|
||||
|
||||
if result.get("errno") == 0:
|
||||
data = result.get("data")
|
||||
print(json.dumps(data, ensure_ascii=False, indent=2))
|
||||
elif result.get("errno") == 110003:
|
||||
print("Cookie 已过期,请重新运行 fengxiang_scraper.py 完成登录")
|
||||
else:
|
||||
print(f"请求失败: {result}")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user