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: remove redundant local tempfile imports
Laith Weinbergere239d1f523bc
diff --git a/browser_use/browser/profile.py b/browser_use/browser/profile.pyindex fd8e34171..4d8858a2d 100644--- a/browser_use/browser/profile.py+++ b/browser_use/browser/profile.py@@ -430,14 +430,14 @@ class BrowserLaunchArgs(BaseModel):if self.downloads_path is None:import uuid- # Create unique directory in /tmp for downloads+ # Create unique directory in system temp folder for downloadsunique_id = str(uuid.uuid4())[:8] # 8 characters- downloads_path = Path(f'/tmp/browser-use-downloads-{unique_id}')+ downloads_path = Path(tempfile.gettempdir()) / f'browser-use-downloads-{unique_id}'# Ensure path doesn't already exist (extremely unlikely but possible)while downloads_path.exists():unique_id = str(uuid.uuid4())[:8]- downloads_path = Path(f'/tmp/browser-use-downloads-{unique_id}')+ downloads_path = Path(tempfile.gettempdir()) / f'browser-use-downloads-{unique_id}'self.downloads_path = downloads_pathself.downloads_path.mkdir(parents=True, exist_ok=True)@@ -1153,7 +1153,6 @@ async function initialize(checkInitialized, magic) {{zip_data = f.read()# Write ZIP data to temp file and extract- import tempfilewith tempfile.NamedTemporaryFile(suffix='.zip', delete=False) as temp_zip:temp_zip.write(zip_data)diff --git a/browser_use/code_use/service.py b/browser_use/code_use/service.pyindex e4f5b54d3..440a4a984 100644--- a/browser_use/code_use/service.py+++ b/browser_use/code_use/service.py@@ -6,6 +6,7 @@ import htmlimport jsonimport loggingimport re+import tempfileimport tracebackfrom pathlib import Pathfrom typing import Any@@ -175,7 +176,7 @@ class CodeAgent:# Initialize screenshot service for eval trackingself.id = uuid7str()timestamp = datetime.datetime.now().strftime('%Y%m%d_%H%M%S')- base_tmp = Path('/tmp')+ base_tmp = Path(tempfile.gettempdir())self.agent_directory = base_tmp / f'browser_use_code_agent_{self.id}_{timestamp}'self.screenshot_service = ScreenshotService(agent_directory=self.agent_directory)