This commit is contained in:
HuangHai
2026-01-13 21:58:42 +08:00
parent 46f17aed11
commit e25aa5b756
11 changed files with 309 additions and 34 deletions

View File

@@ -198,17 +198,18 @@ class YiLaiTeCrawler(BaseCrawler):
logger.info("向下滚动以获取更多电价信息(从底部向上滑)...")
# User feedback: 必须放在下方,向上滚动
w, h = d.window_size()
# start_y=0.9 (底部), end_y=0.4 (上部)
d.swipe(w * 0.5, h * 0.9, w * 0.5, h * 0.4, 0.5)
await asyncio.sleep(1.5)
# 调整滑动参数:避开底部导航栏,增加滑动距离,放慢速度
# start_y=0.75, end_y=0.25
d.swipe(w * 0.5, h * 0.75, w * 0.5, h * 0.25, 0.8)
await asyncio.sleep(2.0) # 增加等待时间,确保滚动停止
# 截图2 (底部)
shot2 = take_screenshot(d, f"detail_price_{clean_station_name(name)}_{int(time.time())}_2")
detail_shots.append(shot2)
# 关闭分时段定价列表 (点击屏幕上半部分空白处)
# 关闭分时段定价列表 (点击屏幕最顶部空白处)
logger.info("点击屏幕上部空白处以关闭定价列表...")
d.click(w * 0.5, h * 0.2)
d.click(w * 0.5, h * 0.1)
await asyncio.sleep(1.0)
else:
logger.info("未发现‘阶段性电价’按钮,直接分析当前页")
@@ -305,11 +306,13 @@ class YiLaiTeCrawler(BaseCrawler):
except Exception as e:
logger.error(f"后台分析 {station_name} 失败: {e}")
finally:
if isinstance(image_paths, list):
for p in image_paths:
if os.path.exists(p): os.remove(p)
elif isinstance(image_paths, str) and os.path.exists(image_paths):
os.remove(image_paths)
# 调试阶段暂时不删除截图,方便排查 VLM 识别失败原因
pass
# if isinstance(image_paths, list):
# for p in image_paths:
# if os.path.exists(p): os.remove(p)
# elif isinstance(image_paths, str) and os.path.exists(image_paths):
# os.remove(image_paths)
async def main(service=None):
if service is None: