优化前端

This commit is contained in:
Jimmy
2026-05-07 15:18:30 +08:00
parent 5c7e489e1c
commit 031ec4d289
5 changed files with 377 additions and 92 deletions

View File

@@ -224,8 +224,17 @@ def fetch_receipt_details_incremental():
log("INFO", f"⏳ 停顿 {delay:.2f} 秒后点击下一页...")
time.sleep(delay)
next_btn_xpath = 'xpath://*[@id="app"]/div/div[1]/div[2]/div[2]/div[1]/div[2]/div/div[2]/div[1]/button[2]'
next_btn = page.ele(next_btn_xpath, timeout=5)
# 同步全量脚本的优化:重试机制与兼容的类名匹配
next_btn = None
for _ in range(3):
next_btn = page.ele('xpath://button[contains(@class, "btn-next")]', timeout=3)
if next_btn:
break
time.sleep(1)
# 备用定位方式:直接找右箭头图标所在的按钮
if not next_btn:
next_btn = page.ele('xpath://i[contains(@class, "el-icon-arrow-right")]/parent::button', timeout=3)
if next_btn:
try: next_btn.click()
@@ -236,7 +245,7 @@ def fetch_receipt_details_incremental():
log("ERR", f"{current_page + 1} 页请求超时!")
break
else:
log("ERR", "找不到下一页按钮!")
log("ERR", "重试 3 次后仍然找不到下一页按钮!")
break
current_page += 1
@@ -246,8 +255,13 @@ def fetch_receipt_details_incremental():
except Exception as e:
log("ERR", f"发生全局异常: {e}")
finally:
conn.close()
page.listen.stop()
if 'conn' in locals() and conn:
conn.close()
if 'page' in locals() and page:
try:
page.listen.stop()
except Exception:
pass
if __name__ == "__main__":
fetch_receipt_details_incremental()