使用场景

把文档网站变成 markdown,用于 RAG 索引

抓取整个文档网站或其中一部分,以干净的 markdown 获取每个页面,可直接分块并嵌入,用于 RAG 聊天机器人或搜索。按页面数量计费。

预付费,无订阅REST 或 MCP一个密钥搞定模型、数据和智能体
Weblovelyjsonitems[0]"url": "https://docs.example.…"markdown": "# Setup ...""depth": 1"startUrl": "https://docs.example.…

基于你的文档作答的客服机器人或编程助手,能答得多好,取决于你喂给索引的文本质量。手动复制页面会漏掉新页面,而原始 HTML 会让索引里塞满菜单和脚本。Lovely Router 抓取整个网站,并把每个页面以干净的 markdown 返回:发送一个起始 URL,每个页面返回一个 JSON 对象,按页面数量从预付费余额中计费。用一个 API 密钥,就能从夜间任务或 AI 智能体中调用。

交给你的 AI 智能体

把这段提示词复制到 Claude Code、Cursor、Codex 或任何编程智能体中。它会告诉智能体文档在哪里,以及如何使用你的 API 密钥。

把文档网站变成 markdown,用于 RAG 索引. Use the Lovely Router data tools: each returns JSON and is billed per result.

- Docs (read first): https://lovelyrouter.com/docs/tools/find.md and https://lovelyrouter.com/docs/tools/run.md
- Plan first: POST https://lovelyrouter.com/v1/tools/suggest with `{"task": "<my task in plain words>"}` (free). It returns the tools to run in order, each with an example `input`, the `input_required` fields, an estimated cost and a ready-made `run` request. Replace the example values with my task's; if a field is unclear, read the tool with GET https://lovelyrouter.com/v1/tools/<id>. To browse instead, POST https://lovelyrouter.com/v1/tools/discover searches the catalog.
- Show me the plan and its estimated cost (`total_est_cost_usd`) before running anything large.
- Run: POST https://lovelyrouter.com/v1/tools/<id>/run with `{"input": {...}, "max_results": N}`. A 200 has the finished run with `items`; a 202 means it is still running, so poll the `poll` path until `status` is `succeeded`, `failed`, `timed_out` or `stopped`.
- Only delivered results are billed. Keep max_results small on the first run, check the output, then scale up.
- If you support MCP, connect https://lovelyrouter.com/mcp instead (Streamable HTTP, same key; https://lovelyrouter.com/docs/tools/mcp.md) and use suggest_tools, get_tool and run_tool.
- Auth: read my API key from the LOVELY_API_KEY environment variable and send it as `Authorization: Bearer $LOVELY_API_KEY`. Never print or commit the key. If it is not set, ask me to create one at https://lovelyrouter.com/app/keys.
- Billing is prepaid: every call is charged to my balance, so test with a small request before running anything large.
- Every docs page is plain Markdown; the full index is https://lovelyrouter.com/llms.txt.

My task: <the inputs (links, keywords or accounts) and how many results you need>
01

工作原理

010203
  1. 选择起始 URL

    使用文档首页,或你需要的某个部分,例如某个指南目录。默认情况下,爬虫也会覆盖该 URL 下的子页面。

  2. 设置上限后运行工具

    把输入连同 max_results 发送到 POST /v1/tools/website-crawl/run。用 maxCrawlPages 设置页面数量上限。运行会从你的余额中预留它的最高费用,并以 markdown 返回每个页面。

  3. 分块并嵌入

    按标题拆分 markdown,嵌入各个分块,重新运行时替换索引里的旧页面。

02

一次请求抓取文档的一个部分

把网站抓取为 markdown 接受 startUrls。maxCrawlPages 限制抓取的页面数量,包括起始页面和分页页面;maxCrawlDepth 限制跟进链接的层数:

curl https://lovelyrouter.com/v1/tools/website-crawl/run \
  -H "Authorization: Bearer $LOVELY_API_KEY" \
  -H "content-type: application/json" \
  -d '{
    "input": {
      "startUrls": [
        {
          "url": "https://docs.example.com/guides"
        }
      ],
      "maxCrawlPages": 3,
      "maxCrawlDepth": 1
    },
    "max_results": 3
  }'

用 includeUrlGlobs 和 excludeUrlGlobs 扩大或缩小抓取范围,用 useSitemaps 把网站 sitemap 中的 URL 加入队列。请让 max_results 与你的页面上限保持一致。运行超过 60 秒仍未结束时会返回 202;轮询方法见运行工具。

03

每个页面包含什么

字段组你会得到
内容干净、适合 LLM 读取的 markdown 页面内容
来源页面 URL,范围限于起始 URL 和你设置的匹配模式
范围只包含符合起始 URL、深度和 glob 模式的页面

先把 maxCrawlPages 设得小一些,确认输出没问题后再抓取整个网站。

04

实用配方

搭建文档聊天机器人。

抓取你的产品文档,按标题对 markdown 分块并嵌入,让机器人回答时附上来源页面的链接。

每晚刷新索引。

用相同的限制重新运行抓取,只替换发生变化的页面。

只索引某一个部分。

从 API 参考目录开始,并为更新日志添加一个排除模式。

为编程智能体提供某个库的文档。

抓取你所用库的文档,让智能体直接检索,而不是凭空猜测。

利用 sitemap。

启用 useSitemaps,或把 sitemap.xml 加为起始 URL,就能抓取到没有任何链接指向的页面。

更想直接用自然语言提问?连接 MCP 服务器,然后对 Claude Code 或 Cursor 说:"把 https://docs.example.com/guides 抓取为 markdown,最多 50 个页面,并把每个页面写入 docs/。将 max_results 设为 50。"

06

费用说明

按页面付费:启动运行时会预留它的最高费用,即每次调用费加上每页费用乘以 max_results,结束后按实际返回的结果结算,预留的剩余部分退回你的余额。失败或超时的运行只为已交付的页面付费,在开始时就被拒绝的运行不收费。

抓取 200 个页面,就按 200 个页面计费,所以设置页面上限可以避免大型网站产生高额账单。没有订阅,也没有每月最低消费:最低充值 $5,工具和模型共用一个余额。上方卡片显示的是当前价格;价格页面列出了所有工具。

07

常见问题

?
如何让抓取只限于某一个部分?+

从该部分的 URL 开始;起始 URL 下的子页面默认会被抓取。需要调整时,添加 includeUrlGlobs 或 excludeUrlGlobs。

一次运行最多能抓取多少个页面?+

通过 maxCrawlPages 最多可设为 200。默认值是 10。

能使用 sitemap 吗?+

可以,使用 useSitemaps,或者把 sitemap.xml 链接加为起始 URL。

能处理基于 JavaScript 的文档网站吗?+

该工具会在浏览器中渲染页面,所以用 JavaScript 生成内容的页面,也会按它呈现的样子被读取。

可以抓取不属于我的网站吗?+

该工具读取的是公开页面。决定抓取哪些内容时,请遵守网站的条款和 robots 规则。

需要订阅吗?+

不需要。你向预付费余额充值,每次运行从中扣费。失败的运行只为已交付的结果付费,不会自动续费。

只想读取单个页面?请看从任何网站提取结构化数据,以及其余的工具目录。

一个预付费密钥,搞定模型、数据和智能体

无需订阅。充值后按需使用,每笔费用都能在日志中查看。