Эх сурвалжийг харах

fix(spider): 修复爬虫请求头和接口调用及定时任务配置问题

- 将User-Agent修改为安卓模拟器,避免部分请求被拒绝
- 移除代理参数,直接请求以提高稳定性
- 更新接口地址至最新的getActEndList接口
- 注释掉立即运行的任务,避免启动时重复执行任务
- 保持定时任务每日午夜自动执行抓取功能
charley 4 долоо хоног өмнө
parent
commit
4df7666a6e

+ 7 - 4
zc_spider/zc_new_daily_spider.py

@@ -22,7 +22,7 @@ BASE_URL = "https://cashier.yqszpay.com"
 PAGE_SIZE = 10
 
 headers = {
-    "User-Agent": user_agent.generate_user_agent(),
+    "User-Agent": user_agent.generate_user_agent(os="android"), # 设置为安卓模拟器
     "Connection": "Keep-Alive",
     "Accept-Encoding": "gzip",
     "Content-Type": "application/json",
@@ -93,7 +93,8 @@ def make_encrypted_post_request(log, url: str, request_data: dict, extra_headers
     encrypted_body = CryptoHelper.encrypt_request_data(request_data)
     # print(request_headers)
     # response = requests.post(url, headers=request_headers, json=encrypted_body, timeout=22, proxies=get_proxys(log))
-    response = requests.post(url, headers=request_headers, json=encrypted_body, timeout=(5, 30), proxies=get_proxys(log))
+    # response = requests.post(url, headers=request_headers, json=encrypted_body, timeout=(5, 30), proxies=get_proxys(log))
+    response = requests.post(url, headers=request_headers, json=encrypted_body, timeout=(5, 30))
     # response.raise_for_status()
 
     if response.status_code == 200:
@@ -138,7 +139,9 @@ def get_sold_single_page(log, mer_no, page_num):
     :param page_num: 页码
     """
     log.info(f"Getting sold items for mer_no: {mer_no}, page: {page_num}")
-    url = f"{BASE_URL}/zc-api/act/actProduct/getActList"
+    # url = f"{BASE_URL}/zc-api/act/actProduct/getActList"
+    # url = "https://cashier.yqszpay.com/zc-api/act/actProduct/getActEndList" 20260407接口变化 修改
+    url = f"{BASE_URL}/zc-api/act/actProduct/getActEndList"
     request_data = {
         'merNo': mer_no,
         'pageNum': page_num,
@@ -531,7 +534,7 @@ def schedule_task():
     爬虫模块 定时任务 的启动文件
     """
     # 立即运行一次任务
-    zc_main(log=logger)
+    # zc_main(log=logger)
 
     # 设置定时任务
     schedule.every().day.at("00:01").do(zc_main, log=logger)