fix: 修复截图只截取可见区域的问题

改为对iframe内容进行截图而不是主页面,这样full_page=True才能正确截取iframe内的完整内容。

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2025-12-14 16:04:36 +08:00
parent 4510fbba83
commit 4400ded86a

View File

@@ -1361,18 +1361,24 @@ class PlaywrightAutomation:
# 先保存到临时文件 # 先保存到临时文件
temp_filepath = filepath + '.tmp' temp_filepath = filepath + '.tmp'
# 使用最高质量设置截图 # 获取iframe并截取完整内容
# type='jpeg' 指定JPEG格式支持quality参数 iframe = self.get_iframe_safe()
# quality=100 表示100%的JPEG质量范围0-100最高质量 if iframe:
# full_page=True 表示截取整个页面 # 对iframe内容进行全页截图
# 视口分辨率 2560x1440 确保高清晰度 iframe.screenshot(
# 这样可以生成更清晰的截图大小约500KB-1MB左右 path=temp_filepath,
self.main_page.screenshot( type='jpeg',
path=temp_filepath, full_page=True,
type='jpeg', quality=100
full_page=True, )
quality=100 else:
) # 如果无法获取iframe回退到主页面截图
self.main_page.screenshot(
path=temp_filepath,
type='jpeg',
full_page=True,
quality=100
)
# 验证文件是否成功创建且大小合理 # 验证文件是否成功创建且大小合理
if not os.path.exists(temp_filepath): if not os.path.exists(temp_filepath):