Skip to content

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

Flight example

magmuellered6510963dc9
diff --git a/examples/flight_search.py b/examples/flight_search.py
index 2846c78bd..44be1542d 100644
--- a/examples/flight_search.py
+++ b/examples/flight_search.py
@@ -7,6 +7,9 @@ Simple try of the agent.
import os
import sys
+from browser_use.browser.browser import Browser, BrowserConfig
+from browser_use.browser.context import BrowserContext, BrowserContextConfig
+
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
import asyncio
@@ -16,20 +19,23 @@ from browser_use import Agent, AgentHistoryList, Controller
llm = ChatOpenAI(model='gpt-4o')
# browser = Browser(config=BrowserConfig(headless=False))
-controller = Controller()
agent = Agent(
- task='Find flights on kayak.com from Zurich to Beijing on 25.12.2024 to 02.02.2025',
+ task=(
+ 'Find flights on kayak.com from Zurich to San Francisco on 25.12.2024 to 02.02.2025, make sure to select the right month '
+ ),
llm=llm,
- controller=controller,
- # browser=browser,
+ validate_output=True,
+ browser_context=BrowserContext(
+ browser=Browser(config=BrowserConfig(headless=False)),
+ ),
)
async def main():
- history: AgentHistoryList = await agent.run(2)
+ history: AgentHistoryList = await agent.run(20)
# await controller.browser.close(force=True)
-
+ input('Press Enter to close the browser')
# await browser.close()