'commit'
This commit is contained in:
@@ -158,7 +158,9 @@ async def get_station_list(d, service, max_stations_count=MAX_STATIONS_COUNT):
|
||||
|
||||
# 正常处理新场站
|
||||
click_x, click_y = card["click_point"]
|
||||
logger.info(f">>> 发现新场站 '{station_name}',开始处理... ({total_encountered_count}/{max_stations_count})")
|
||||
current_idx = total_encountered_count
|
||||
remaining = max_stations_count - current_idx
|
||||
logger.info(f"--- [进度: {current_idx}/{max_stations_count}, 剩余: {remaining}] 发现新场站 '{station_name}',开始处理... ---")
|
||||
new_stations_processed_in_page += 1
|
||||
total_new_processed_count += 1
|
||||
d.click(click_x, click_y)
|
||||
|
||||
Binary file not shown.
@@ -242,7 +242,9 @@ async def get_station_list(d, service, uploader, max_stations_count=MAX_STATIONS
|
||||
continue
|
||||
|
||||
# 正常处理新场站
|
||||
logger.info(f">>> 发现新场站 '{station_name}',开始处理... ({total_encountered_count}/{max_stations_count})")
|
||||
current_idx = total_encountered_count
|
||||
remaining = max_stations_count - current_idx
|
||||
logger.info(f"--- [进度: {current_idx}/{max_stations_count}, 剩余: {remaining}] 发现新场站 '{station_name}',开始处理... ---")
|
||||
new_stations_processed_in_page += 1
|
||||
total_new_processed_count += 1
|
||||
|
||||
|
||||
Binary file not shown.
@@ -71,12 +71,13 @@ class YiLaiTeCrawler(BaseCrawler):
|
||||
await self.redis_kit.delete(*keys)
|
||||
|
||||
async def crawl_list_logic(self, d):
|
||||
max_to_crawl = 1 if FIRST_RUN_ONLY_ONE_STATION else MAX_STATIONS_COUNT
|
||||
processed_count = 0
|
||||
no_new_data_count = 0
|
||||
last_md5 = None
|
||||
background_tasks = []
|
||||
|
||||
while processed_count < MAX_STATIONS_COUNT:
|
||||
while processed_count < max_to_crawl:
|
||||
# 1. 截图并分析
|
||||
screenshot_path = take_screenshot(d, f"list_{int(time.time())}.jpg")
|
||||
|
||||
@@ -102,7 +103,7 @@ class YiLaiTeCrawler(BaseCrawler):
|
||||
no_new_data_count = 0
|
||||
new_stations_in_page = 0
|
||||
for station in stations:
|
||||
if processed_count >= MAX_STATIONS_COUNT:
|
||||
if processed_count >= max_to_crawl:
|
||||
break
|
||||
|
||||
name = station.get('name')
|
||||
@@ -119,41 +120,14 @@ class YiLaiTeCrawler(BaseCrawler):
|
||||
logger.info(f"场站 {name} 已处理过,跳过")
|
||||
continue
|
||||
|
||||
# --- 新增逻辑:立即中断当前页面的后续遍历,先处理当前这个场站 ---
|
||||
# 因为一旦点击进入二级页面再返回,列表页的状态可能会变(如滚动位置微调),
|
||||
# 或者之前的坐标已经失效。为了稳健,每次处理完一个点击跳转,都应该重新截图分析列表页。
|
||||
# 但重新截图分析成本太高,所以至少应该确保处理完这一个后,不会盲目点击后续的旧坐标。
|
||||
#
|
||||
# 然而,当前逻辑是遍历 `stations` 列表。如果第一个场站点击并返回了,
|
||||
# 后面的 `stations` 中的坐标可能已经不准了(如果返回时页面刷新了)。
|
||||
#
|
||||
# 观察日志发现:"发现第一场站后,没有进去查看二级,而是直接退回了小程序的搜索页面"
|
||||
# 这说明可能是 `d.press("back")` 的逻辑有问题,或者页面结构导致 `back` 行为不一致。
|
||||
#
|
||||
# 针对用户反馈:"发现第一场站后,没有进去查看二级,而是直接退回了小程序的搜索页面"
|
||||
# 这通常是因为在列表页点击后,并没有真正进入二级页(也许点偏了,或者加载慢),
|
||||
# 然后程序认为进去了,执行了 `back`,结果把列表页关了退回了搜索页。
|
||||
#
|
||||
# 现在的代码已经加了 MD5 校验 `if before_md5 != after_md5`,理论上能防住这个问题。
|
||||
# 但用户最新的反馈是:"没有马上进入第一个卡片对应的二级,而是向下继续滚动了去获取更多的场站了"
|
||||
# 这意味着 `before_md5 != after_md5` 判断为 False,认为没进去,所以跳过了处理,继续循环。
|
||||
#
|
||||
# 为什么明明点击了却没进去?
|
||||
# 1. 坐标点偏了?测试脚本显示点是红心,应该是准的。
|
||||
# 2. 点击操作被某些透明层拦截了?
|
||||
# 3. 页面还没加载完全?
|
||||
#
|
||||
# 让我们增加点击后的重试机制,或者微调点击位置。
|
||||
# 另外,如果点击没进去,不应该直接 continue,应该尝试 debug 或者稍微移动一下位置再点。
|
||||
#
|
||||
# 这里我们加一个重试点击逻辑
|
||||
current_idx = processed_count + 1
|
||||
remaining = max_to_crawl - current_idx
|
||||
logger.info(f"--- [进度: {current_idx}/{max_to_crawl}, 剩余: {remaining}] 发现新场站: {name} (坐标: {point}, 距离: {distance}) ---")
|
||||
|
||||
# 点击进入前截图,用于对比是否成功进入二级页
|
||||
before_click_path = take_screenshot(d, f"before_{clean_station_name(name)}")
|
||||
before_md5 = get_image_content_md5(before_click_path, top_ratio=SAFE_EXCLUDE_RATIO, bottom_ratio=BOTTOM_SAFE_EXCLUDE_RATIO)
|
||||
|
||||
# 点击进入
|
||||
logger.info(f">>> 发现新场站: {name} 坐标: {point}")
|
||||
# 稍微等待一下,确保 UI 稳定
|
||||
await asyncio.sleep(0.5)
|
||||
# 使用 input tap 替代 d.click,提高点击成功率 (部分小程序对 click 响应不佳)
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user