mirror of
https://github.com/browser-use/browser-use.git
synced 2026-09-14 19:59:47 +08:00
32 lines
777 B
Plaintext
32 lines
777 B
Plaintext
---
|
|
title: "Events"
|
|
description: "Monitor execution with callbacks"
|
|
icon: "bell"
|
|
---
|
|
|
|
## Live Browser View
|
|
|
|
```python
|
|
@sandbox(on_browser_created=lambda data: print(f'👁️ {data.live_url}'))
|
|
async def task(browser: Browser):
|
|
agent = Agent(task="your task", browser=browser, llm=ChatBrowserUse())
|
|
await agent.run()
|
|
```
|
|
|
|
## All Events
|
|
|
|
```python
|
|
from browser_use.sandbox import BrowserCreatedData, LogData, ResultData, ErrorData
|
|
|
|
@sandbox(
|
|
on_browser_created=lambda data: print(f'Live: {data.live_url}'),
|
|
on_log=lambda log: print(f'{log.level}: {log.message}'),
|
|
on_result=lambda result: print('Done!'),
|
|
on_error=lambda error: print(f'Error: {error.error}'),
|
|
)
|
|
async def task(browser: Browser):
|
|
# Your code
|
|
```
|
|
|
|
All callbacks can be sync or async.
|