mineru-extract

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

MinerU Extract (official API)

MinerU Extract(官方API)

Use MinerU as an upstream “content normalizer”: submit a URL to MinerU, poll for completion, download the result zip, and extract the main Markdown.
将MinerU作为上游“内容标准化工具”:向MinerU提交URL,轮询任务完成状态,下载结果压缩包,并提取主Markdown文件。

Quick start (MCP-aligned)

快速开始(对齐MCP)

We align to the MinerU MCP mental model, but we do not run an MCP server.
  • Primary script (MCP-style):
    scripts/mineru_parse_documents.py
    • Input:
      --file-sources
      (comma/newline-separated)
    • Output: JSON contract on stdout:
      { ok, items, errors }
  • Low-level script (single URL):
    scripts/mineru_extract.py
Auth:
  • Set
    MINERU_TOKEN
    (Bearer token from mineru.net)
Default model heuristic:
  • URLs ending with
    .pdf/.doc/.ppt/.png/.jpg
    pipeline
  • Otherwise →
    MinerU-HTML
    (best for HTML pages like WeChat articles)
我们遵循MinerU MCP的思维模型,但我们不运行MCP服务器。
  • 主脚本(MCP风格):
    scripts/mineru_parse_documents.py
    • 输入:
      --file-sources
      (逗号/换行分隔)
    • 输出:标准输出的JSON协议
      { ok, items, errors }
  • 底层脚本(单URL):
    scripts/mineru_extract.py
认证:
  • 设置
    MINERU_TOKEN
    (来自mineru.net的Bearer令牌)
默认模型启发式规则:
  • .pdf/.doc/.ppt/.png/.jpg
    结尾的URL → 使用
    pipeline
    模型
  • 其他URL → 使用
    MinerU-HTML
    (最适合微信文章等HTML页面)

1) Configure token (skill-local)

1) 配置令牌(技能本地)

Put secrets in skill root
.env
(do not paste into chat outputs):
bash
undefined
将密钥放在技能根目录
.env
文件中(请勿粘贴到聊天输出中):
bash
undefined

In the mineru-extract skill directory: .env

在mineru-extract技能目录下的.env文件

MINERU_TOKEN=your_token_here MINERU_API_BASE=https://mineru.net
undefined
MINERU_TOKEN=your_token_here MINERU_API_BASE=https://mineru.net
undefined

2) Parse URL(s) → Markdown (recommended)

2) 解析URL(s) → Markdown(推荐方式)

MCP-style wrapper (returns JSON, optionally includes markdown text):
bash
python3 mineru-extract/scripts/mineru_parse_documents.py \
  --file-sources "<URL1>\n<URL2>" \
  --language ch \
  --enable-ocr \
  --model-version MinerU-HTML
If you want the markdown content inline in the JSON (can be large):
bash
python3 mineru-extract/scripts/mineru_parse_documents.py \
  --file-sources "<URL>" \
  --model-version MinerU-HTML \
  --emit-markdown --max-chars 20000
Low-level (single URL, print markdown to stdout):
bash
python3 mineru-extract/scripts/mineru_extract.py "<URL>" --model MinerU-HTML --print > /tmp/out.md
MCP风格的封装脚本(返回JSON,可选择包含Markdown文本):
bash
python3 mineru-extract/scripts/mineru_parse_documents.py \
  --file-sources "<URL1>\n<URL2>" \
  --language ch \
  --enable-ocr \
  --model-version MinerU-HTML
如果希望Markdown内容内嵌在JSON中(内容可能较大):
bash
python3 mineru-extract/scripts/mineru_parse_documents.py \
  --file-sources "<URL>" \
  --model-version MinerU-HTML \
  --emit-markdown --max-chars 20000
底层调用(单URL,将Markdown打印到标准输出):
bash
python3 mineru-extract/scripts/mineru_extract.py "<URL>" --model MinerU-HTML --print > /tmp/out.md

Output

输出

The script always downloads + extracts the MinerU result zip to:
~/.openclaw/workspace/mineru/<task_id>/
It writes:
  • result.zip
  • extracted files (Markdown + JSON + assets)
It prints a JSON summary to stderr with paths:
  • task_id
    ,
    full_zip_url
    ,
    out_dir
    ,
    markdown_path
脚本始终会将MinerU的结果压缩包下载并提取到:
~/.openclaw/workspace/mineru/<task_id>/
它会写入:
  • result.zip
  • 提取后的文件(Markdown + JSON + 资源文件)
它会在标准错误输出中打印包含路径的JSON摘要:
  • task_id
    ,
    full_zip_url
    ,
    out_dir
    ,
    markdown_path

Parameters (common)

通用参数

  • --model
    :
    pipeline | vlm | MinerU-HTML
    (HTML requires
    MinerU-HTML
    )
  • --ocr/--no-ocr
    : enable OCR (effective for
    pipeline
    /
    vlm
    )
  • --table/--no-table
    : table recognition
  • --formula/--no-formula
    : formula recognition
  • --language ch|en|...
  • --page-ranges "2,4-6"
    (non-HTML)
  • --timeout 600
    /
    --poll-interval 2
  • --model
    :
    pipeline | vlm | MinerU-HTML
    (HTML页面需使用
    MinerU-HTML
  • --ocr/--no-ocr
    : 启用OCR(对
    pipeline
    /
    vlm
    模型有效)
  • --table/--no-table
    : 表格识别
  • --formula/--no-formula
    : 公式识别
  • --language ch|en|...
  • --page-ranges "2,4-6"
    (非HTML内容适用)
  • --timeout 600
    /
    --poll-interval 2

Failure modes & fallbacks

失败模式与回退方案

  • MinerU may fail to fetch some URLs (anti-bot / geo / login).
    • Fallback: provide an HTML file or a PDF/long screenshot; then implement “upload + parse” flow with MinerU batch upload endpoints.
    • Always report the failing URL + MinerU
      err_msg
      and keep an original-source link in outputs.
  • MinerU可能无法获取某些URL的内容(反爬/地域限制/需要登录)。
    • 回退方案:提供HTML文件或PDF/长截图;然后使用MinerU批量上传端点实现“上传+解析”流程。
    • 请始终报告失败的URL + MinerU的
      err_msg
      ,并在输出中保留原始源链接。

References

参考资料