'commit'
This commit is contained in:
@@ -6,7 +6,7 @@ import sys
|
||||
import json
|
||||
import time
|
||||
from datetime import datetime
|
||||
from Apps.YeLiTe.Kit import take_screenshot, clean_station_name, get_image_content_md5, find_template
|
||||
from Apps.YeLiTe.Kit import take_screenshot, clean_station_name, get_image_content_md5, detect_price_info_container_cv
|
||||
from Apps.YeLiTe.ReadImageKit import ReadImageKit
|
||||
from Apps.YeLiTe.Service import YiLaiTeService
|
||||
from Apps.YeLiTe.Config.Setting import (
|
||||
@@ -107,6 +107,7 @@ class YiLaiTeCrawler(BaseCrawler):
|
||||
|
||||
name = station.get('name')
|
||||
address = station.get('address')
|
||||
distance = station.get('distance')
|
||||
point = station.get('point')
|
||||
|
||||
if not name or not point:
|
||||
@@ -182,7 +183,9 @@ class YiLaiTeCrawler(BaseCrawler):
|
||||
logger.info(f"成功进入详情页: {name}")
|
||||
|
||||
# --- 新增:点击“阶段性电价”按钮以获取完整电价列表 ---
|
||||
dqdf_pos = find_template(detail_shot, "dqdf.jpg")
|
||||
# 使用 OCR 探测价格入口
|
||||
dqdf_pos = detect_price_info_container_cv(detail_shot)
|
||||
|
||||
detail_shots = []
|
||||
|
||||
if dqdf_pos:
|
||||
@@ -219,7 +222,7 @@ class YiLaiTeCrawler(BaseCrawler):
|
||||
# --------------------------------------------------
|
||||
|
||||
# 启动后台任务处理详情页
|
||||
task = asyncio.create_task(self.analyze_detail_background(name, detail_shots, address=address))
|
||||
task = asyncio.create_task(self.analyze_detail_background(name, detail_shots, address=address, distance=distance))
|
||||
background_tasks.append(task)
|
||||
|
||||
processed_count += 1
|
||||
@@ -268,7 +271,7 @@ class YiLaiTeCrawler(BaseCrawler):
|
||||
|
||||
return processed_count
|
||||
|
||||
async def analyze_detail_background(self, station_name, image_paths, address=None):
|
||||
async def analyze_detail_background(self, station_name, image_paths, address=None, distance=None):
|
||||
"""
|
||||
后台异步分析详情页 (支持多张截图合并)
|
||||
"""
|
||||
@@ -304,8 +307,8 @@ class YiLaiTeCrawler(BaseCrawler):
|
||||
unique_prices.sort(key=lambda x: x.get('start', '00:00'))
|
||||
|
||||
if unique_prices:
|
||||
await self.service.process_price_detail_data(station_name, unique_prices, address=address)
|
||||
logger.info(f"场站 {station_name} 价格分析完成并入库 (记录数: {len(unique_prices)}, 地址: {address})")
|
||||
await self.service.process_price_detail_data(station_name, unique_prices, address=address, distance=distance)
|
||||
logger.info(f"场站 {station_name} 价格分析完成并入库 (记录数: {len(unique_prices)}, 地址: {address}, 距离: {distance})")
|
||||
else:
|
||||
logger.warning(f"场站 {station_name} 未识别到价格信息")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user