'commit'
This commit is contained in:
@@ -7,7 +7,7 @@ import json
|
||||
import cv2
|
||||
from Apps.TeLaiDian.Kit import (
|
||||
take_screenshot, get_image_content_md5, clean_station_name,
|
||||
setup_logger, read_image, save_image, detect_warm_popup_xczs_cv
|
||||
setup_logger, read_image, save_image, detect_warm_popup_xczs_cv, get_name_md5
|
||||
)
|
||||
from Apps.TeLaiDian.ReadImageKit import ReadImageKit
|
||||
from Apps.TeLaiDian.FirstPageKit import run_ocr_rect
|
||||
@@ -208,6 +208,8 @@ class TeLaiDianCrawler(BaseCrawler):
|
||||
remaining = max_to_crawl - current_idx
|
||||
logger.info(f"--- [进度: {current_idx}/{max_to_crawl}, 剩余: {remaining}] 处理场站: {name} (坐标: {point}, 距离: {distance}) ---")
|
||||
|
||||
file_tag = get_name_md5(name)
|
||||
|
||||
# 组装基础场站信息,便于详情页逻辑使用
|
||||
station_info = {
|
||||
"name": name,
|
||||
@@ -223,7 +225,7 @@ class TeLaiDianCrawler(BaseCrawler):
|
||||
await asyncio.sleep(WAIT_DETAIL_PAGE_LOAD)
|
||||
|
||||
# 截图验证是否进入详情页
|
||||
detail_check_path = take_screenshot(d, f"tld_detail_check_{int(time.time())}.jpg")
|
||||
detail_check_path = take_screenshot(d, f"tld_detail_check_{file_tag}_{int(time.time())}.jpg")
|
||||
logger.info(f"详情页快照已保存: {detail_check_path}")
|
||||
|
||||
# 简单验证:如果标题包含 "我的卡券"、"优惠券"、"新人福利" 等,说明点错了
|
||||
@@ -300,7 +302,7 @@ class TeLaiDianCrawler(BaseCrawler):
|
||||
"""
|
||||
在详情页提取价格和状态信息
|
||||
"""
|
||||
first_screen_path = take_screenshot(d, f"tld_detail_basic_{int(time.time())}.jpg")
|
||||
first_screen_path = take_screenshot(d, f"tld_detail_basic_{get_name_md5(station_name)}_{int(time.time())}.jpg")
|
||||
station_name = station_info.get("name")
|
||||
address = station_info.get("address")
|
||||
distance = station_info.get("distance")
|
||||
@@ -456,7 +458,7 @@ class TeLaiDianCrawler(BaseCrawler):
|
||||
max_scroll_down_pages = 8
|
||||
for p_idx in range(1, max_scroll_down_pages + 1):
|
||||
# 截图当前页
|
||||
p_shot = take_screenshot(d, f"tld_detail_price_{int(time.time())}_{p_idx}.jpg")
|
||||
p_shot = take_screenshot(d, f"tld_detail_price_{get_name_md5(station_name)}_{int(time.time())}_{p_idx}.jpg")
|
||||
|
||||
# 检查是否还能向下滚动
|
||||
before_dn_md5 = get_image_content_md5(p_shot)
|
||||
|
||||
@@ -48,6 +48,13 @@ def get_file_md5(file_path):
|
||||
for chunk in iter(lambda: f.read(4096), b""):
|
||||
hash_md5.update(chunk)
|
||||
return hash_md5.hexdigest()
|
||||
|
||||
def get_name_md5(name):
|
||||
if not name:
|
||||
return "unknown"
|
||||
if not isinstance(name, str):
|
||||
name = str(name)
|
||||
return hashlib.md5(name.encode("utf-8")).hexdigest()
|
||||
|
||||
def get_image_content_md5(file_path, top_ratio=0.1, bottom_ratio=0.1):
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user