Skip to content

Open-source Python library for AI browser agents, plus Browser Use Cloud: stealth browsers and a hosted agent API.

Refactor download_file example to use updated Browser class

Magnus Müller495804389cb2
diff --git a/examples/features/download_file.py b/examples/features/download_file.py
index edaf15870..a9d67b49f 100644
--- a/examples/features/download_file.py
+++ b/examples/features/download_file.py
@@ -9,7 +9,7 @@ from dotenv import load_dotenv
load_dotenv()
-from browser_use import Agent, BrowserProfile, BrowserSession, ChatGoogle
+from browser_use import Agent, Browser, ChatGoogle
api_key = os.getenv('GOOGLE_API_KEY')
if not api_key:
@@ -18,14 +18,14 @@ if not api_key:
llm = ChatGoogle(model='gemini-2.5-flash', api_key=api_key)
-browser_session = BrowserSession(browser_profile=BrowserProfile(downloads_path='~/Downloads/tmp'))
+browser = Browser(downloads_path='~/Downloads/tmp')
async def run_download():
agent = Agent(
task='Go to "https://file-examples.com/" and download the smallest doc file. then go back and get the next file.',
llm=llm,
- browser_session=browser_session,
+ browser=browser,
)
await agent.run(max_steps=25)