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
bla
Gregor Žunič7a73e02bb4fd
diff --git a/examples/bla.py b/examples/bla.pynew file mode 100644index 000000000..1604c3fed--- /dev/null+++ b/examples/bla.py@@ -0,0 +1,60 @@+"""+Browser Use Cloud Demo - Simple Web Scraping+Demonstrates Browser Use's cloud-hosted browser for web scraping.+"""++import asyncio++from dotenv import load_dotenv++from browser_use import Agent, Browser, remote_execute+from browser_use.llm.browser_use.chat import ChatBrowserUse+from browser_use.remote_execute.views import BrowserCreatedData++# Load environment variables+load_dotenv()+++async def on_browser_created(browser: BrowserCreatedData):+ print(f'Browser created: {browser.live_url}')+++@remote_execute(log_level='INFO', on_browser_created=on_browser_created)+async def runner(browser: Browser):+ print('\nBrowser Use Cloud Demo - Hacker News Top Articles')+ print('=' * 50)+ print('Extracting top 3 Hacker News articles with summaries...\n')++ # configure any agent provider+ llm = ChatBrowserUse()+ # llm=ChatAnthropic(model='claude-sonnet-4-0')+ # llm = ChatOpenAI(model="chatgpt-4o-latest")+ # llm = ChatGroq(model= "moonshotai/kimi-k2-instruct")o++ agent = Agent(+ task=(+ """+ Go to news.ycombinator.com and for each of the top 3 articles, list:+ title:+ url:+ summary:+ separated by newlines.+ """+ ),+ llm=llm,+ browser=browser,+ )++ result = await agent.run()+ print(result.structured_output)++ return result+++async def main():+ history = await runner()+ print(history)+++if __name__ == '__main__':+ asyncio.run(main())diff --git a/examples/remote_execution.py b/examples/remote_execution.pynew file mode 100644index 000000000..b095e16c7--- /dev/null+++ b/examples/remote_execution.py@@ -0,0 +1,58 @@+"""Example of using remote execution with Browser-Use Agent++This example demonstrates how to use the @remote_execute decorator to run+browser automation tasks with the Agent on remote infrastructure.++To run this example:+1. Set your BROWSER_USE_API_KEY environment variable+2. Set your LLM API key (OPENAI_API_KEY, ANTHROPIC_API_KEY, etc.)+3. Run: python examples/remote_execution.py+"""++import asyncio+import os++from browser_use import AgentHistoryList, Browser, ChatBrowserUse, remote_execute+from browser_use.agent.service import Agent+++# Example with event callbacks to monitor execution+def on_browser_ready(data):+ """Callback when browser session is created"""+ print('\n🌐 Browser session created!')+ print(f' Session ID: {data.session_id}')+ print(f' Live view: {data.live_url}')+ print(' Click the link above to watch the AI agent work!\n')+++@remote_execute(log_level='INFO', on_browser_created=on_browser_ready)+async def pydantic_example(browser: Browser) -> AgentHistoryList:+ agent = Agent(+ """got of to https://news.ycombinator.com/ and find the latest top 5 news and each top comment""",+ browser=browser,+ # output_model_schema=HackernewsPosts,+ llm=ChatBrowserUse(),+ )+ res = await agent.run()++ return res+++async def main():+ """Run examples"""+ # Check if API keys are set+ if not os.getenv('BROWSER_USE_API_KEY'):+ print('❌ Please set BROWSER_USE_API_KEY environment variable')+ return++ print('\n\n=== Search with AI Agent (with live browser view) ===')++ search_result = await pydantic_example()++ print(f'\n✅ Search completed with {len(search_result.history)} actions')+ print('\nResults:')+ print(search_result.final_result())+++if __name__ == '__main__':+ asyncio.run(main())