mcpField
J
jb-docs-scraper

jb-docs-scraper

github.com/bjesuiter文档处理036 次安装1 周前更新
代码仓库

关于 jb-docs-scraper

jb-docs-scraper 可抓取文档网站,并将页面保存为本地 Markdown 文件,适合需要本地文档副本的用户。它支持 URL 过滤,并可控制抓取深度和页面数量。

主要功能

  1. 01通过广度优先搜索抓取文档
  2. 02识别域名和 URL 模式
  3. 03按 URL 模式筛选页面
  4. 04将页面转换为 Markdown
  5. 05按 URL 路径组织输出目录
  6. 06设置抓取深度和页面上限

适用场景

  1. 01保存文档网站以供本地查阅
  2. 02将抓取范围限制在文档子目录
  3. 03控制试运行抓取的规模
  4. 04更新本地 Markdown 文档副本

安装

复制下面的命令,在终端中运行。

$npx skills add https://github.com/bjesuiter/skills --skill jb-docs-scraper

安装后在 Claude Code 中输入/jb-docs-scraper确认已加载。

附带文件references/scrape_docs.py

详细介绍

文档爬取工具

将任意文档网站爬取为本地 Markdown 文件。使用 crawl4ai 进行异步网页爬取。

快速开始

# Scrape any documentation URL
uv run --with crawl4ai python ./references/scrape_docs.py <URL>

# Examples
uv run --with crawl4ai python ./references/scrape_docs.py https://mediasoup.org/documentation/v3/
uv run --with crawl4ai python ./references/scrape_docs.py https://docs.rombo.co/tailwind

默认将输出保存到 ./docs/<auto-detected-name>/。

前置条件(仅首次运行时需要)

uv run --with crawl4ai playwright install

用法

uv run --with crawl4ai python ./references/scrape_docs.py <URL> [OPTIONS]
选项
选项描述默认值
-o, --output PATH输出目录./docs/<auto-detected-name>
--max-depth N最大链接深度6
--max-pages N要爬取的最大页面数500
--url-pattern PATTERNURL 过滤器(glob)自动检测
-q, --quiet禁止输出详细信息False
示例
# Basic - scrape to ./docs/documentation_v3/
uv run --with crawl4ai python ./references/scrape_docs.py \
  https://mediasoup.org/documentation/v3/

# Custom output directory
uv run --with crawl4ai python ./references/scrape_docs.py \
  https://docs.rombo.co/tailwind \
  --output ./my-tailwind-docs

# Limit crawl scope
uv run --with crawl4ai python ./references/scrape_docs.py \
  https://tanstack.com/start/latest/docs/framework/react/overview \
  --max-pages 50 \
  --max-depth 3

# Custom URL pattern filter
uv run --with crawl4ai python ./references/scrape_docs.py \
  https://example.com/docs/api/v2/ \
  --url-pattern "*api/v2/*"

工作原理

  1. 自动检测输入 URL 的域名和 URL 模式
  2. 使用 BFS(广度优先搜索)策略爬取
  3. 过滤内容,确保范围不超出文档专区
  4. 将页面转换为整洁的 Markdown
  5. 按照与 URL 路径相对应的目录结构保存

输出结构

docs/<name>/
  index.md           # Root page
  getting-started.md
  api/
    overview.md
    client.md
  guides/
    installation.md

故障排除

问题解决方案
Playwright browser binaries are missing运行 uv run --with crawl4ai playwright install
输出为空检查 URL 模式是否匹配实际文档 URL。试试 --url-pattern
页面缺失增大 --max-depth 或 --max-pages
爬取了错误的页面使用更严格的 --url-pattern

提示

  1. 先测试——使用 --max-pages 10,在完整爬取前验证配置
  2. 检查输出名称——脚本会根据 URL 路径段自动检测
  3. 可安全重新运行——文件会被覆盖,重复项会被跳过

评论

支持 Markdown