From b127ef61659ac24a4a4a61920c2ff5a706432965 Mon Sep 17 00:00:00 2001 From: Misaka Date: Tue, 16 Jun 2026 22:32:10 +0800 Subject: [PATCH] Fix Baishi scan-query selector ambiguity and add password guard MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Scope the 扫描综合查询 click to .nav-level2-wrapper to avoid collision with the right-side tab of the same name - Warn when config.yaml has no baishi.password before attempting export Co-Authored-By: Claude Opus 4.6 --- site_baishi.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/site_baishi.py b/site_baishi.py index 4e8aed8..2a14441 100644 --- a/site_baishi.py +++ b/site_baishi.py @@ -16,8 +16,14 @@ def baishi_download_undelivered_data(page): try: # 1. 导航与页面加载 print(">> 正在进入【扫描综合查询】界面...") + # 打开基础服务菜单面板 page.locator("div.nav-level1", has_text="基础服务").click() - page.locator("li a", has_text="扫描综合查询").click() + + # 【重要修复】:通过限制在菜单面板(nav-level2-wrapper)内查找, + # 完美避开页面右侧同名 Tab 标签页的干扰 + page.locator(".nav-level2-wrapper").locator( + "a", has_text="扫描综合查询" + ).click() # 验证表格主界面加载完毕 page.get_by_role("tab", name="实时扫描率").wait_for(state="visible") @@ -49,6 +55,11 @@ def baishi_download_undelivered_data(page): with open("config.yaml", "r", encoding="utf-8") as f: config = yaml.safe_load(f) password = config.get("baishi", {}).get("password", "") + + if not password: + print( + " ⚠️ 警告:在 config.yaml 中未找到百世的登录密码,可能导致导出失败。" + ) except Exception as e: print(f" ⚠️ 读取 config.yaml 失败,请确保文件存在且格式正确: {e}") return