This commit is contained in:
HuangHai
2026-01-13 20:01:57 +08:00
parent a9b0d125d2
commit 099f8fb148
4 changed files with 24 additions and 16 deletions

View File

@@ -110,6 +110,10 @@ async def get_station_list(d, service, max_stations_count=MAX_STATIONS_COUNT):
new_stations_processed = 0
if json_metadata.get("cards") and stations:
for card_idx, card in enumerate(json_metadata["cards"]):
# 检查是否已达到最大采集数量
if total_processed_count >= max_stations_count:
break
# 检查索引是否越界 (VL 模型可能返回的数组长度不一致)
if card_idx < len(stations) and stations[card_idx]:
station = stations[card_idx]
@@ -233,10 +237,7 @@ async def get_station_list(d, service, max_stations_count=MAX_STATIONS_COUNT):
full_name_key = f"crawled:aite:{Kit.clean_station_name(station_name)}"
await redis_kit.set_data(full_name_key, "1", expire=REDIS_STATION_EXPIRE)
# 检查是否已达到最大采集数量
if total_processed_count >= max_stations_count:
logger.info(f"已达到目标采集数量 {max_stations_count},准备结束采集。")
break
# 如果内层循环已达上限,外层循环也应退出,避免不必要的滑动
if total_processed_count >= max_stations_count:
break