Commit 968f8b9d authored by 邱阿朋's avatar 邱阿朋

fix(vc): 修复分页按钮不存在时的异常处理

- 引入 ElementNotFoundError 异常捕获机制
- 使用 try-except 捕获分页按钮查找失败的情况
- 添加分页按钮为空时的判空处理
- 在分页按钮不存在时记录详细日志并跳过翻页操作
- 增强分页按钮判断的鲁棒性与稳定性
parent 070a860c
......@@ -5,6 +5,7 @@ from datetime import datetime
import pandas as pd
from DrissionPage import ChromiumPage as Page
from DrissionPage.errors import ElementNotFoundError
from lxml import etree
from app.helper import domain, file
......@@ -90,8 +91,13 @@ class AdvertCost(AutoInterface):
time.sleep(5)
# 判断分页按钮是否存在
if self.page.ele('#products_view:products_view:pagination-dropdown',timeout=5) is None:
self.logger.debug("分页按钮不存在,跳过翻页")
try:
pagination_element = self.page.ele('#products_view:products_view:pagination-dropdown', timeout=5).html
if pagination_element is None or pagination_element == "":
self.logger.debug("分页按钮不存在,跳过翻页")
return
except ElementNotFoundError as e:
self.logger.debug(f"分页按钮不存在或查找失败,跳过翻页: {str(e)}")
return
# 点击分页按钮
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment