MCPcopy
hub / github.com/unclecode/crawl4ai / capture_and_save_screenshot

Function capture_and_save_screenshot

docs/examples/quickstart_async.py:81–101  ·  view source on GitHub ↗
(url: str, output_path: str)

Source from the content-addressed store, hash-verified

79 # print(result.markdown[:500]) # Print first 500 characters
80
81async def capture_and_save_screenshot(url: str, output_path: str):
82 async with AsyncWebCrawler(verbose=True) as crawler:
83 result = await crawler.arun(
84 url=url,
85 screenshot=True,
86 bypass_cache=True
87 )
88
89 if result.success and result.screenshot:
90 import base64
91
92 # Decode the base64 screenshot data
93 screenshot_data = base64.b64decode(result.screenshot)
94
95 # Save the screenshot as a JPEG file
96 with open(output_path, 'wb') as f:
97 f.write(screenshot_data)
98
99 print(f"Screenshot saved successfully to {output_path}")
100 else:
101 print("Failed to capture screenshot")
102
103class OpenAIModelFee(BaseModel):
104 model_name: str = Field(..., description="Name of the OpenAI model.")

Callers 1

mainFunction · 0.85

Calls 2

AsyncWebCrawlerClass · 0.90
arunMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…