XFE Git
XFE Studio Git
Git 首页 全局搜索
XFE 主站 文档 NuGet
公开
关注 0 Fork 0 Star 1
返回提交历史

XFEstudio/gpt4free

Refactor screenshot handling in CDPSession to return file path instead of image bytes

493db463
hlohaus <983577+hlohaus@users.noreply.github.com>
提交于

代码差异

1 个文件 +2 -3
Modified g4f/requests/cdp.py +2 -3
@@ -786,10 +786,9 @@ class CDPSession:
786 786 screenshot_dir = get_screenshot_dir(datekey)
787 787 filename = f"{secure_filename(url.replace('https://', '').replace('http://', ''))}.jpg"
788 788 filepath = os.path.join(screenshot_dir, filename)
789 debug.log(f"Screenshot path: {filepath}")
790 789
791 790 if os.path.exists(filepath):
792 return Path(filepath).read_bytes()
791 return filepath
793 792
794 793 debug.log(f"Capturing screenshot for {url} ...")
795 794 await self.navigate(url)
@@ -822,7 +821,7 @@ class CDPSession:
822 821 image_bytes = output.getvalue()
823 822
824 823 Path(filepath).write_bytes(image_bytes)
825 return image_bytes
824 return filepath
826 825
827 826 async def close(self):
828 827 """Close WebSocket session, close the specific target tab, and close the browser."""