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