'commit'
This commit is contained in:
@@ -218,7 +218,7 @@ class TeLaiDianCrawler(BaseCrawler):
|
||||
logger.info(f"详情页快照已保存: {detail_check_path}")
|
||||
|
||||
# 简单验证:如果标题包含 "我的卡券"、"优惠券"、"新人福利" 等,说明点错了
|
||||
is_wrong_page = await self.check_wrong_page(d, detail_check_path)
|
||||
is_wrong_page = await self.check_wrong_page(d, detail_check_path, context="detail")
|
||||
if is_wrong_page:
|
||||
logger.warning(f"检测到进入了错误页面,尝试返回列表...")
|
||||
# 尝试点击左上角的返回箭头,如果没有,则执行系统 back
|
||||
@@ -268,15 +268,24 @@ class TeLaiDianCrawler(BaseCrawler):
|
||||
self.pending_price_tasks.clear()
|
||||
logger.info("[收尾] 后台价格任务已全部完成")
|
||||
|
||||
async def check_wrong_page(self, d, image_path):
|
||||
async def check_wrong_page(self, d, image_path, context="list"):
|
||||
"""
|
||||
检查是否误触进入了错误的页面(如:我的卡券、活动页等)
|
||||
"""
|
||||
data = await self.read_image_kit.check_wrong_page_vlm(image_path)
|
||||
is_detail = data.get("is_detail_page", True)
|
||||
if not is_detail:
|
||||
logger.warning(f"⚠️ 确认进入错误页面: {data.get('page_type')} ({data.get('reason')})")
|
||||
return not is_detail
|
||||
page_type = data.get("page_type")
|
||||
reason = data.get("reason")
|
||||
|
||||
if is_detail:
|
||||
return False
|
||||
|
||||
if context == "detail" and page_type == "other":
|
||||
logger.warning(f"⚠️ 详情页首轮检测结果为 other,将视为加载异常页面,继续尝试解析。原因: {reason}")
|
||||
return False
|
||||
|
||||
logger.warning(f"⚠️ 确认进入错误页面: {page_type} ({reason})")
|
||||
return True
|
||||
|
||||
async def crawl_detail_logic(self, d, station_info):
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user