The webscraper tool is unable to scrape pdfurl #20270

Closed
opened 2026-02-21 20:06:35 -05:00 by yindo · 4 comments
Owner

Originally created by @doit-5618 on GitHub (Nov 12, 2025).

Self Checks

  • I have read the Contributing Guide and Language Policy.
  • This is only for bug report, if you would like to ask a question, please head to Discussions.
  • I have searched for existing issues search for existing issues, including closed ones.
  • I confirm that I am using English to submit this report, otherwise it will be closed.
  • 【中文用户 & Non English User】请使用英语提交,否则会被关闭 :)
  • Please do not modify this template :) and fill in all the required fields.

Dify version

1.8.1

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

When using the "webscraper" tool and passing in multiple PDFURLs, errors may occur at individual urls, as shown in the following figure.

Image

I ensure that pdfurl is correct and can be opened normally through browsers such as chroma and edge.
My question is as follows:
May I ask what the decision boundary of the failed analysis is? What kind of PDFurl will have errors and what kind will be parsed normally?
2. Without using third-party libraries such as pypdf2, is there a solution for dify to replace webscraper tools?

✔️ Expected Behavior

The pdf was parsed normally

Actual Behavior

No response

Originally created by @doit-5618 on GitHub (Nov 12, 2025). ### Self Checks - [x] I have read the [Contributing Guide](https://github.com/langgenius/dify/blob/main/CONTRIBUTING.md) and [Language Policy](https://github.com/langgenius/dify/issues/1542). - [x] This is only for bug report, if you would like to ask a question, please head to [Discussions](https://github.com/langgenius/dify/discussions/categories/general). - [x] I have searched for existing issues [search for existing issues](https://github.com/langgenius/dify/issues), including closed ones. - [x] I confirm that I am using English to submit this report, otherwise it will be closed. - [x] 【中文用户 & Non English User】请使用英语提交,否则会被关闭 :) - [x] Please do not modify this template :) and fill in all the required fields. ### Dify version 1.8.1 ### Cloud or Self Hosted Self Hosted (Docker) ### Steps to reproduce When using the "webscraper" tool and passing in multiple PDFURLs, errors may occur at individual urls, as shown in the following figure. <img width="753" height="516" alt="Image" src="https://github.com/user-attachments/assets/6d08311d-4b52-4335-9c4c-59f82233b65d" /> I ensure that pdfurl is correct and can be opened normally through browsers such as chroma and edge. My question is as follows: May I ask what the decision boundary of the failed analysis is? What kind of PDFurl will have errors and what kind will be parsed normally? 2. Without using third-party libraries such as pypdf2, is there a solution for dify to replace webscraper tools? ### ✔️ Expected Behavior The pdf was parsed normally ### ❌ Actual Behavior _No response_
yindo added the 🌚 invalid label 2026-02-21 20:06:35 -05:00
yindo closed this issue 2026-02-21 20:06:35 -05:00
Author
Owner
@doit-5618 commented on GitHub (Nov 12, 2025): Failed pdf url: http://www.sse.com.cn/disclosure/bond/announcement/company/c/new/2024-05-23/240344_20240523_L6SR.pdf
Author
Owner

@doit-5618 commented on GitHub (Nov 12, 2025):

Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.1000.0 Safari/537.36

@doit-5618 commented on GitHub (Nov 12, 2025): Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.1000.0 Safari/537.36
Author
Owner

@dosubot[bot] commented on GitHub (Nov 12, 2025):

The "Failed to load document (PDFium: Data format error)" happens when Dify's PDF extractor (using pypdfium2/PDFium) encounters a PDF it can't parse—usually due to things like image-only PDFs, embedded fonts, encryption, or non-standard/corrupted structure. If a PDF opens in browsers but fails in Dify, it's likely because PDFium is stricter about format compliance than browser viewers. There isn't a built-in alternative in Dify that avoids third-party libraries for PDF parsing; all PDF extraction relies on pypdfium2, and switching to something like PyPDF2 or PyMuPDF would require code changes source.

For PDFs with images or scanned content, Dify can't extract text or perform OCR. You'd need to extract images manually and upload them separately if you want to process them source. Some LLM models (like Sonnet or Gemini) support direct PDF processing, which you can try in an agent app source.

The webscraper tool supports custom user-agent strings, but by default uses a Chrome-like agent. If a site blocks scraping based on user-agent, you can set your own string in the tool parameters source.

If you keep hitting this error, try re-saving the PDF with another tool, check for corruption, or experiment with alternative libraries outside Dify. For now, the decision boundary is set by what PDFium can successfully parse.

To reply, just mention @dosu.


How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other  Chat with Dosu Join Discord Share on X

@dosubot[bot] commented on GitHub (Nov 12, 2025): <!-- Answer --> The "Failed to load document (PDFium: Data format error)" happens when Dify's PDF extractor (using pypdfium2/PDFium) encounters a PDF it can't parse—usually due to things like image-only PDFs, embedded fonts, encryption, or non-standard/corrupted structure. If a PDF opens in browsers but fails in Dify, it's likely because PDFium is stricter about format compliance than browser viewers. There isn't a built-in alternative in Dify that avoids third-party libraries for PDF parsing; all PDF extraction relies on pypdfium2, and switching to something like PyPDF2 or PyMuPDF would require code changes [source](https://github.com/langgenius/dify/blob/90f77282e36e376df2932f9779dfa6fd6680ae83/api/core/rag/extractor/pdf_extractor.py). For PDFs with images or scanned content, Dify can't extract text or perform OCR. You'd need to extract images manually and upload them separately if you want to process them [source](https://github.com/langgenius/dify/issues/24853). Some LLM models (like Sonnet or Gemini) support direct PDF processing, which you can try in an agent app [source](https://github.com/langgenius/dify/issues/12745). The webscraper tool supports custom user-agent strings, but by default uses a Chrome-like agent. If a site blocks scraping based on user-agent, you can set your own string in the tool parameters [source](https://github.com/langgenius/dify/blob/90f77282e36e376df2932f9779dfa6fd6680ae83/api/core/tools/builtin_tool/providers/webscraper/tools/webscraper.py). If you keep hitting this error, try re-saving the PDF with another tool, check for corruption, or experiment with alternative libraries outside Dify. For now, the decision boundary is set by what PDFium can successfully parse. <!-- Dosu Comment Footer --> *To reply, just mention [@dosu](https://go.dosu.dev/dosubot).* --- <sup>How did I do? [Good](https://app.dosu.dev/response-feedback/8d400cb2-b2a0-4d57-8f67-52000ad01098?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/8d400cb2-b2a0-4d57-8f67-52000ad01098?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/8d400cb2-b2a0-4d57-8f67-52000ad01098?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/8d400cb2-b2a0-4d57-8f67-52000ad01098?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/8d400cb2-b2a0-4d57-8f67-52000ad01098?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/8d400cb2-b2a0-4d57-8f67-52000ad01098?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/8d400cb2-b2a0-4d57-8f67-52000ad01098?feedback_type=other)</sup>&nbsp;&nbsp;[![Chat with Dosu](https://dosu.dev/dosu-chat-badge.svg)](https://app.dosu.dev/6088a4f4-073a-43f3-b3d4-4f06fb0c05a0/ask?utm_source=github)&nbsp;[![Join Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[![Share on X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/langgenius/dify/issues/28110)
Author
Owner

@crazywoola commented on GitHub (Nov 12, 2025):

You can read the source code to see why this is failed, it's not possible to rely on a simple extract tool to extract complex materials.

@crazywoola commented on GitHub (Nov 12, 2025): You can read the source code to see why this is failed, it's not possible to rely on a simple extract tool to extract complex materials.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#20270