Skip to content

[Bug]: Can't fetch the downloaded file #1566

@mikurisan

Description

@mikurisan

crawl4ai version

0.7.4

Expected Behavior

fetch the downloaded file using downloaded_files attribute.

Current Behavior

downloaded_files attr is None even though the target file has been downloaded successfully.

Is this reproducible?

Yes

Inputs Causing the Bug

Steps to Reproduce

Code snippets

async def download_detail_pdf(self, query_url: str):
        """Click "export" button to download the pdf file of current detail page."""
        wait_for_button = ".long-project-property-right > div:nth-child(3)"
        config1 = CrawlerRunConfig(
            session_id=self.session_id,
            wait_for=wait_for_button,
            js_only=True
        )
        await self.crawler.arun(query_url, config=config1)

        js_click_button = """
        const selector = ".long-project-property-right > div:nth-child(3)";
        const button = document.querySelector(selector);
        if (button) button.click();
        """
        config2 = CrawlerRunConfig(
            session_id=self.session_id,
            js_code=js_click_button,
            wait_for=1
        )
        result = await self.crawler.arun(query_url, config=config2)
        

        if result.downloaded_files:
            for file_path in result.downloaded_files:
                print("=====================")
                print(file_path)
        
        return None

OS

Windows

Python version

3.11

Browser

Chrome

Browser version

No response

Error logs & Screenshots (if applicable)

...
[SCRAPE].. ◆ https://qiye.qianlima.com/new_qd_yfbsite/#/infoC...archPage&isFirstZhaobiao=false&searchKeyWord=机器人  | ✓ | ⏱: 0.08s 
[COMPLETE] ● https://qiye.qianlima.com/new_qd_yfbsite/#/infoC...archPage&isFirstZhaobiao=false&searchKeyWord=机器人  | ✓ | ⏱: 0.35s 
====================================================
None
[FETCH]... ↓ https://qiye.qianlima.com/new_qd_yfbsite/#/infoC...archPage&isFirstZhaobiao=false&searchKeyWord=机器人  | ✓ | ⏱: 0.31s 
[SCRAPE].. ◆ https://qiye.qianlima.com/new_qd_yfbsite/#/infoC...archPage&isFirstZhaobiao=false&searchKeyWord=机器人  | ✓ | ⏱: 0.10s 
[COMPLETE] ● https://qiye.qianlima.com/new_qd_yfbsite/#/infoC...archPage&isFirstZhaobiao=false&searchKeyWord=机器人  | ✓ | ⏱: 0.41s 
[FETCH]... ↓ Downloading 国产智能化腔镜手术机器人整机制造及应用.pdf to D:/data\国产智能化腔镜手术机器人整机制造及应用.pdf 
...
[COMPLETE] ● Downloaded 国产智能化腔镜手术机器人整机制造及应用.pdf successfully 
...

Metadata

Metadata

Assignees

No one assigned

    Labels

    🐞 BugSomething isn't working🩺 Needs TriageNeeds attention of maintainers

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions