Open-source Python library for AI browser agents, plus Browser Use Cloud: stealth browsers and a hosted agent API.
Python ai-agentsai-toolsbrowser-agentbrowser-automationbrowser-usecdpcloud-browsercomputer-useheadless-browserllmmcpplaywrightpythonremote-browserstealth-browserweb-automationweb-scraping
Fix cookies
magmueller47cd2daff521
diff --git a/browser_use/browser/service.py b/browser_use/browser/service.pyindex 8f5e87bd6..e72089950 100644--- a/browser_use/browser/service.py+++ b/browser_use/browser/service.py@@ -546,9 +546,12 @@ class Browser:try:cookies = await self.session.context.cookies()logger.info(f'Saving {len(cookies)} cookies to {self.cookies_file}')- # maybe file is just a file name then i get- if os.path.dirname(self.cookies_file):- os.makedirs(os.path.dirname(self.cookies_file), exist_ok=True)++ # Check if the path is a directory and create it if necessary+ dirname = os.path.dirname(self.cookies_file)+ if dirname:+ os.makedirs(dirname, exist_ok=True)+with open(self.cookies_file, 'w') as f:json.dump(cookies, f)except Exception as e: