diff --git a/Apps/TeLaiDian/Crawler.py b/Apps/TeLaiDian/Crawler.py index adad8ce..d477335 100644 --- a/Apps/TeLaiDian/Crawler.py +++ b/Apps/TeLaiDian/Crawler.py @@ -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}") diff --git a/Apps/TeLaiDian/Template/qbsd.jpg b/Apps/TeLaiDian/Template/qbsd.jpg new file mode 100644 index 0000000..3a5fcb4 Binary files /dev/null and b/Apps/TeLaiDian/Template/qbsd.jpg differ diff --git a/Apps/TelaiDian/__pycache__/Crawler.cpython-310.pyc b/Apps/TelaiDian/__pycache__/Crawler.cpython-310.pyc index 9f5187e..129ef88 100644 Binary files a/Apps/TelaiDian/__pycache__/Crawler.cpython-310.pyc and b/Apps/TelaiDian/__pycache__/Crawler.cpython-310.pyc differ