Skip to content

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

Real browser example

Magnus Müllercc481d4cfd4f
diff --git a/examples/browser/real_browser.py b/examples/browser/real_browser.py
index 9d5cae8b0..d416a9ad3 100644
--- a/examples/browser/real_browser.py
+++ b/examples/browser/real_browser.py
@@ -8,30 +8,27 @@ from dotenv import load_dotenv
load_dotenv()
-from browser_use import Agent
-from browser_use.browser import BrowserProfile, BrowserSession
-from browser_use.llm import ChatOpenAI
+from browser_use import Agent, BrowserProfile, BrowserSession, ChatOpenAI
+
+# SETUP: First copy your real Chrome profile (close Chrome first, then run):
+# Mac:
+# mkdir -p ~/.config/browseruse/profiles && cp -r ~/Library/Application\ Support/Google/Chrome ~/.config/browseruse/profiles/real-chrome
+
browser_profile = BrowserProfile(
- # NOTE: you need to close your chrome browser - so that this can open your browser in debug mode
executable_path='/Applications/Google Chrome.app/Contents/MacOS/Google Chrome',
- user_data_dir='~/.config/browseruse/profiles/default',
- headless=False,
+ user_data_dir='~/.config/browseruse/profiles/real-chrome',
)
browser_session = BrowserSession(browser_profile=browser_profile)
async def main():
agent = Agent(
- task='Find todays DOW stock price',
- llm=ChatOpenAI(model='gpt-4.1'),
+ llm=ChatOpenAI(model='gpt-4.1-mini'),
+ task='Visit https://duckduckgo.com and search for "browser-use founders"',
browser_session=browser_session,
)
-
await agent.run()
- await browser_session.kill()
-
- input('Press Enter to close...')
if __name__ == '__main__':