File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -260,6 +260,7 @@ Ready-to-run examples are available in `examples/`:
260260- ` examples/sync_scrape.py `
261261- ` examples/async_extract.py `
262262- ` examples/sync_web_search.py `
263+ - ` examples/async_web_search.py `
263264
264265## License
265266
Original file line number Diff line number Diff line change 1+ """
2+ Example: asynchronous web search with the Hyperbrowser SDK.
3+
4+ Run:
5+ export HYPERBROWSER_API_KEY="your_api_key"
6+ python3 examples/async_web_search.py
7+ """
8+
9+ import asyncio
10+
11+ from hyperbrowser import AsyncHyperbrowser
12+ from hyperbrowser .models import WebSearchParams
13+
14+
15+ async def main () -> None :
16+ async with AsyncHyperbrowser () as client :
17+ response = await client .web .search (
18+ WebSearchParams (
19+ query = "Hyperbrowser Python SDK" ,
20+ page = 1 ,
21+ )
22+ )
23+
24+ print (f"Job ID: { response .job_id } " )
25+ print (f"Status: { response .status } " )
26+
27+ if not response .data :
28+ print ("No results returned." )
29+ return
30+
31+ print (f"Query: { response .data .query } " )
32+ for index , result in enumerate (response .data .results [:5 ], start = 1 ):
33+ print (f"{ index } . { result .title } -> { result .url } " )
34+
35+
36+ if __name__ == "__main__" :
37+ asyncio .run (main ())
You can’t perform that action at this time.
0 commit comments