unclecode / crawl4ai

🔥🕷️ Crawl4AI: Open-source LLM Friendly Web Crawler & Scrapper
Apache License 2.0
16.63k stars 1.23k forks source link

fix: screenshot were not saved into AsyncCrawlResponse #139

Open Jacky97s opened 1 month ago

Jacky97s commented 1 month ago

Description

This pull request addresses an issue where the screenshot functionality in AsyncWebCrawler is not working as expected, leading to an assertion error.

Issue

When using the sample code to run the crawler with screenshot=True, an AssertionError is raised because the result.screenshot is None:

Sample Code:

async with AsyncWebCrawler(verbose=False) as crawler:
    result = await crawler.arun(url="https://example.com", screenshot=True, bypass_cache=True)

    assert result.success is True
    assert result.screenshot is not None, "Screenshot is None"

Output

    assert result.screenshot is not None, "Screenshot is None"
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: Screenshot is None