From 4400ded86a14f859427a3c3de27d23ac83b45db5 Mon Sep 17 00:00:00 2001 From: yuyx <237899745@qq.com> Date: Sun, 14 Dec 2025 16:04:36 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E6=88=AA=E5=9B=BE?= =?UTF-8?q?=E5=8F=AA=E6=88=AA=E5=8F=96=E5=8F=AF=E8=A7=81=E5=8C=BA=E5=9F=9F?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 改为对iframe内容进行截图而不是主页面,这样full_page=True才能正确截取iframe内的完整内容。 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- playwright_automation.py | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/playwright_automation.py b/playwright_automation.py index 2207d94..9831b8b 100755 --- a/playwright_automation.py +++ b/playwright_automation.py @@ -1361,18 +1361,24 @@ class PlaywrightAutomation: # 先保存到临时文件 temp_filepath = filepath + '.tmp' - # 使用最高质量设置截图 - # type='jpeg' 指定JPEG格式(支持quality参数) - # quality=100 表示100%的JPEG质量(范围0-100,最高质量) - # full_page=True 表示截取整个页面 - # 视口分辨率 2560x1440 确保高清晰度 - # 这样可以生成更清晰的截图,大小约500KB-1MB左右 - self.main_page.screenshot( - path=temp_filepath, - type='jpeg', - full_page=True, - quality=100 - ) + # 获取iframe并截取完整内容 + iframe = self.get_iframe_safe() + if iframe: + # 对iframe内容进行全页截图 + iframe.screenshot( + path=temp_filepath, + type='jpeg', + 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):