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
improve examples
mertunsalld7046e442cf5
diff --git a/examples/file_system/alphabet_earnings.py b/examples/file_system/alphabet_earnings.pynew file mode 100644index 000000000..7a8bd6fba--- /dev/null+++ b/examples/file_system/alphabet_earnings.py@@ -0,0 +1,56 @@+import asyncio+import os+import pathlib+import shutil++from dotenv import load_dotenv++from browser_use import Agent+from browser_use.browser import BrowserProfile, BrowserSession+from browser_use.llm import ChatOpenAI++load_dotenv()++''+SCRIPT_DIR = pathlib.Path(os.path.dirname(os.path.abspath(__file__)))+agent_dir = SCRIPT_DIR / 'alphabet_earnings'+agent_dir.mkdir(exist_ok=True)++try:+ from lmnr import Laminar++ Laminar.initialize(project_api_key=os.getenv('LMNR_PROJECT_API_KEY'))+except Exception as e:+ print(f'Error initializing Laminar: {e}')++llm = ChatOpenAI(+ model='o4-mini',+)++browser_session = BrowserSession(+ browser_profile=BrowserProfile(downloads_path=str(agent_dir / 'downloads')),+)++task = """+Go to https://abc.xyz/assets/cc/27/3ada14014efbadd7a58472f1f3f4/2025q2-alphabet-earnings-release.pdf.+Read the PDF and save 3 interesting data points in "alphabet_earnings.pdf" and share it with me!+""".strip('\n')++agent = Agent(+ task=task,+ llm=llm,+ browser_session=browser_session,+ file_system_path=str(agent_dir / 'fs'),+ flash_mode=True,+)+++async def main():+ agent_history = await agent.run()+ input('Press Enter to clean the file system...')+ # clean the file system+ shutil.rmtree(str(agent_dir / 'fs'))+++if __name__ == '__main__':+ asyncio.run(main())diff --git a/examples/file_system/file_system.py b/examples/file_system/file_system.pyindex 78eda7ca3..c54a52881 100644--- a/examples/file_system/file_system.py+++ b/examples/file_system/file_system.py@@ -12,7 +12,7 @@ load_dotenv()''SCRIPT_DIR = pathlib.Path(os.path.dirname(os.path.abspath(__file__)))-agent_dir = SCRIPT_DIR / 'test_no_thinking'+agent_dir = SCRIPT_DIR / 'file_system'agent_dir.mkdir(exist_ok=True)conversation_dir = agent_dir / 'conversations' / 'conversation'print(f'Agent logs directory: {agent_dir}')