返回提交历史
Modified
g4f/requests/cdp.py
+2
-3
XFEstudio/gpt4free
Refactor screenshot handling in CDPSession to return file path instead of image bytes
493db463
代码差异
1 个文件
+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."""