'commit'
This commit is contained in:
@@ -48,6 +48,30 @@ class ReadImageKit:
|
||||
logger.error(f"VLM 寻找价格入口失败: {e}")
|
||||
return {"found": False}
|
||||
|
||||
async def find_close_button_vlm(self, image_path):
|
||||
"""
|
||||
使用 VLM 在页面上寻找关闭按钮(用于清理广告弹窗)
|
||||
"""
|
||||
prompt = """
|
||||
分析这张截图,判断是否存在弹窗广告或遮罩层。
|
||||
如果存在,请找到关闭按钮(通常是圆圈里的 X,或者写着“跳过”、“关闭”的按钮)。
|
||||
|
||||
输出格式为 JSON:
|
||||
{
|
||||
"has_ad": true/false,
|
||||
"reason": "简单描述发现的弹窗",
|
||||
"close_point": [x, y] // 归一化坐标 [0-1000],如果不存在则为 null
|
||||
}
|
||||
"""
|
||||
try:
|
||||
res_text = await self.vlm.analyze_image(image_path, prompt)
|
||||
json_str = self.vlm.extract_json(res_text)
|
||||
data = json.loads(json_str)
|
||||
return data
|
||||
except Exception as e:
|
||||
logger.error(f"VLM 寻找关闭按钮失败: {e}")
|
||||
return {"has_ad": False}
|
||||
|
||||
async def analyze_detail_price(self, image_path):
|
||||
"""
|
||||
分析详情页截图,提取电价信息,包括优惠价、PLUS价和挂牌价
|
||||
|
||||
Reference in New Issue
Block a user