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
docs(cloud): validate example timeout setting
MagMueller1359fb22cbce
diff --git a/examples/cloud/01_basic_task.py b/examples/cloud/01_basic_task.pyindex 1be9d67f7..ce2054245 100644--- a/examples/cloud/01_basic_task.py+++ b/examples/cloud/01_basic_task.py@@ -2,6 +2,7 @@import osimport time+from math import isfinitefrom typing import Anyimport requests@@ -14,7 +15,12 @@ API_KEY = os.getenv('BROWSER_USE_API_KEY')if not API_KEY:raise RuntimeError('Set BROWSER_USE_API_KEY or add it to .env')-RUN_TIMEOUT_SECONDS = float(os.getenv('BROWSER_USE_RUN_TIMEOUT', '900'))+try:+ RUN_TIMEOUT_SECONDS = float(os.getenv('BROWSER_USE_RUN_TIMEOUT', '900'))+except ValueError as error:+ raise RuntimeError('BROWSER_USE_RUN_TIMEOUT must be a positive number of seconds') from error+if not isfinite(RUN_TIMEOUT_SECONDS) or RUN_TIMEOUT_SECONDS <= 0:+ raise RuntimeError('BROWSER_USE_RUN_TIMEOUT must be a positive number of seconds')HEADERS = {'X-Browser-Use-API-Key': API_KEY}TERMINAL_STATUSES = {'completed', 'failed', 'cancelled'}