(url: str, output_path: str)
| 79 | # print(result.markdown[:500]) # Print first 500 characters |
| 80 | |
| 81 | async 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 | |
| 103 | class OpenAIModelFee(BaseModel): |
| 104 | model_name: str = Field(..., description="Name of the OpenAI model.") |
no test coverage detected
searching dependent graphs…