File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -263,6 +263,8 @@ Ready-to-run examples are available in `examples/`:
263263- ` examples/sync_extract.py `
264264- ` examples/sync_crawl.py `
265265- ` examples/async_crawl.py `
266+ - ` examples/sync_web_fetch.py `
267+ - ` examples/async_web_fetch.py `
266268- ` examples/sync_web_search.py `
267269- ` examples/async_web_search.py `
268270- ` examples/sync_session_list.py `
Original file line number Diff line number Diff line change 1+ """
2+ Asynchronous web fetch example.
3+
4+ Run:
5+ export HYPERBROWSER_API_KEY="your_api_key"
6+ python3 examples/async_web_fetch.py
7+ """
8+
9+ import asyncio
10+
11+ from hyperbrowser import AsyncHyperbrowser
12+ from hyperbrowser .models import FetchParams
13+
14+
15+ async def main () -> None :
16+ async with AsyncHyperbrowser () as client :
17+ response = await client .web .fetch (
18+ FetchParams (
19+ url = "https://hyperbrowser.ai" ,
20+ )
21+ )
22+
23+ print (f"Job ID: { response .job_id } " )
24+ print (f"Status: { response .status } " )
25+ if response .data and response .data .markdown :
26+ print (response .data .markdown [:500 ])
27+
28+
29+ if __name__ == "__main__" :
30+ asyncio .run (main ())
Original file line number Diff line number Diff line change 1+ """
2+ Synchronous web fetch example.
3+
4+ Run:
5+ export HYPERBROWSER_API_KEY="your_api_key"
6+ python3 examples/sync_web_fetch.py
7+ """
8+
9+ from hyperbrowser import Hyperbrowser
10+ from hyperbrowser .models import FetchParams
11+
12+
13+ def main () -> None :
14+ with Hyperbrowser () as client :
15+ response = client .web .fetch (
16+ FetchParams (
17+ url = "https://hyperbrowser.ai" ,
18+ )
19+ )
20+
21+ print (f"Job ID: { response .job_id } " )
22+ print (f"Status: { response .status } " )
23+ if response .data and response .data .markdown :
24+ print (response .data .markdown [:500 ])
25+
26+
27+ if __name__ == "__main__" :
28+ main ()
You can’t perform that action at this time.
0 commit comments