File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -258,6 +258,7 @@ Contributor workflow details are available in [CONTRIBUTING.md](CONTRIBUTING.md)
258258Ready-to-run examples are available in ` examples/ ` :
259259
260260- ` examples/async_batch_fetch.py `
261+ - ` examples/async_browser_use_task.py `
261262- ` examples/async_crawl.py `
262263- ` examples/async_extension_create.py `
263264- ` examples/async_extension_list.py `
@@ -271,6 +272,7 @@ Ready-to-run examples are available in `examples/`:
271272- ` examples/async_web_fetch.py `
272273- ` examples/async_web_search.py `
273274- ` examples/sync_batch_fetch.py `
275+ - ` examples/sync_browser_use_task.py `
274276- ` examples/sync_crawl.py `
275277- ` examples/sync_extension_create.py `
276278- ` examples/sync_extension_list.py `
Original file line number Diff line number Diff line change 1+ """
2+ Asynchronous browser-use task example.
3+
4+ Run:
5+ export HYPERBROWSER_API_KEY="your_api_key"
6+ python3 examples/async_browser_use_task.py
7+ """
8+
9+ import asyncio
10+
11+ from hyperbrowser import AsyncHyperbrowser
12+ from hyperbrowser .models .agents .browser_use import StartBrowserUseTaskParams
13+
14+
15+ async def main () -> None :
16+ async with AsyncHyperbrowser () as client :
17+ result = await client .agents .browser_use .start_and_wait (
18+ StartBrowserUseTaskParams (
19+ task = "Open https://example.com and return the page title." ,
20+ )
21+ )
22+ print (f"Job status: { result .status } " )
23+ if result .output is not None :
24+ print (f"Task output: { result .output } " )
25+
26+
27+ if __name__ == "__main__" :
28+ asyncio .run (main ())
Original file line number Diff line number Diff line change 1+ """
2+ Synchronous browser-use task example.
3+
4+ Run:
5+ export HYPERBROWSER_API_KEY="your_api_key"
6+ python3 examples/sync_browser_use_task.py
7+ """
8+
9+ from hyperbrowser import Hyperbrowser
10+ from hyperbrowser .models .agents .browser_use import StartBrowserUseTaskParams
11+
12+
13+ def main () -> None :
14+ with Hyperbrowser () as client :
15+ result = client .agents .browser_use .start_and_wait (
16+ StartBrowserUseTaskParams (
17+ task = "Open https://example.com and return the page title." ,
18+ )
19+ )
20+ print (f"Job status: { result .status } " )
21+ if result .output is not None :
22+ print (f"Task output: { result .output } " )
23+
24+
25+ if __name__ == "__main__" :
26+ main ()
You can’t perform that action at this time.
0 commit comments