jerry 3 kuukautta sitten
vanhempi
sitoutus
d5f47d8a79
4 muutettua tiedostoa jossa 24 lisäystä ja 4 poistoa
  1. 2 0
      docker-compose.yml
  2. 18 0
      plugins/tls_plugin2.py
  3. 3 3
      plugins/vfs_plugin2.py
  4. 1 1
      requirements.txt

+ 2 - 0
docker-compose.yml

@@ -13,6 +13,8 @@ services:
     volumes:
       - ./config:/app/config
       - ./logs:/app/logs
+      - ./data:/app/data
+      - ./plugins:/app/plugins
     environment:
       - TZ=Asia/Shanghai
       - DISPLAY=:99

+ 18 - 0
plugins/tls_plugin2.py

@@ -105,6 +105,21 @@ class TlsPlugin2(IVSPlg):
                 self._log(f"Session expired.")
                 return False
         return True
+    
+    def _save_screenshot(self, name_prefix):
+        try:
+            timestamp = int(time.time())
+            filename = f"{self.instance_id}_{name_prefix}_{timestamp}.jpg"
+            save_path = os.path.join("data", filename)
+            os.makedirs("data", exist_ok=True)
+            
+            # [修改] 改为 full_page=False,防止页面结构异常导致截图失败
+            # 这样能截取到浏览器当前可视区域,最适合调试“卡住”的情况
+            self.page.get_screenshot(path=save_path, full_page=False)
+            
+            self._log(f"Screenshot saved to {save_path}")
+        except Exception as e:
+            self._log(f"Failed to save screenshot: {e}")
 
     def create_session(self):
         """
@@ -202,6 +217,7 @@ class TlsPlugin2(IVSPlg):
                 self._log("Reloading Login Page...")
                 self.page.get(full_login_url)
                 if not self.page.wait.ele_displayed('#email-input-field', timeout=15):
+                    self._save_screenshot("login_load_fail")
                     raise BizLogicError("Login form not loaded")
 
             # --- JS 注入登录 ---
@@ -244,6 +260,7 @@ class TlsPlugin2(IVSPlg):
             if "login-actions" in self.page.url or "auth" in self.page.url:
                 err = "Unknown Login Error"
                 if "Invalid username" in self.page.html: err = "Invalid Credentials"
+                self._save_screenshot("login_submit_fail")
                 raise BizLogicError(f"Login Failed: {err}")
 
             # --- 提取 Dashboard 信息 ---
@@ -262,6 +279,7 @@ class TlsPlugin2(IVSPlg):
                     break
             
             if not self.travel_group:
+                self._save_screenshot("group_not_found")
                 raise NotFoundError(f"Group not found for {target_city}")
             
             self.session_create_time = time.time()

+ 3 - 3
plugins/vfs_plugin2.py

@@ -526,9 +526,9 @@ class VfsPlugin2(IVSPlg):
         # [日志] 记录响应数据
         # ---------------------------------------------------------
         duration = res_dict.get('duration', 0)
-        # 截取过长的响应体,避免日志文件爆炸 (保留前 500 字符)
-        # 如果需要完整分析,可以去掉 [:500]
-        resp_preview = resp.text[:500] + "..." if len(resp.text) > 500 else resp.text
+        # 截取过长的响应体,避免日志文件爆炸 (保留前 1000 字符)
+        # 如果需要完整分析,可以去掉 [:1000]
+        resp_preview = resp.text[:1000] + "..." if len(resp.text) > 1000 else resp.text
         
         self._log(f"┌── [TRAFFIC RESPONSE] Status: {resp.status_code} | Time: {duration}ms")
         self._log(f"└── Body: {resp_preview}")

+ 1 - 1
requirements.txt

@@ -2,7 +2,7 @@ DrissionPage>=4.0.0
 bs4
 cryptography
 curl-cffi>=0.7.0
-ddddocr
+ddddocr==1.4.11
 fastapi
 numpy
 pydantic