This commit is contained in:
HuangHai
2026-01-14 16:04:14 +08:00
parent db8d004294
commit cbbee0491e
3 changed files with 23 additions and 0 deletions

View File

@@ -242,10 +242,33 @@ class TeLaiDianCrawler(BaseCrawler):
await asyncio.sleep(1.0)
template_jgxx = os.path.join(os.path.dirname(__file__), "Template", "jgxx.jpg")
template_qbsd = os.path.join(os.path.dirname(__file__), "Template", "qbsd.jpg")
entrance_point = None
max_search_rounds = 5
if os.path.exists(template_qbsd):
try:
match_res_qbsd = d.image.match(template_qbsd)
except Exception as e:
match_res_qbsd = None
logger.error(f"[详情页] qbsd 模板匹配价格入口失败: {e}")
if match_res_qbsd:
logger.info(f"[详情页] qbsd 模板匹配返回结果: {match_res_qbsd}")
if hasattr(match_res_qbsd, "point") and match_res_qbsd.point:
entrance_point = match_res_qbsd.point
elif isinstance(match_res_qbsd, dict):
if "point" in match_res_qbsd and match_res_qbsd["point"]:
entrance_point = match_res_qbsd["point"]
elif "x" in match_res_qbsd and "y" in match_res_qbsd:
entrance_point = (match_res_qbsd["x"], match_res_qbsd["y"])
elif isinstance(match_res_qbsd, (list, tuple)) and len(match_res_qbsd) >= 2:
entrance_point = (match_res_qbsd[0], match_res_qbsd[1])
if entrance_point:
logger.info(f"[详情页] 通过 qbsd.jpg 成功找到价格入口: {entrance_point}")
for round_idx in range(max_search_rounds):
if entrance_point:
break
search_screen_path = take_screenshot(d, f"tld_detail_search_{int(time.time())}_{round_idx}.jpg")
logger.info(f"[详情页] 搜索价格入口,第 {round_idx + 1}/{max_search_rounds} 轮: {search_screen_path}")

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB