POST /distill — 蒸馏单个页面
将网页转换为干净的、LLM 就绪的 Markdown 格式。
使用场景:- 为 RAG(检索增强生成)准备网页内容
- 提取文章内容用于 AI 处理
- 将文档页面转换为 Markdown
- 处理动态网页应用
- 保留结构的干净 Markdown 内容
- 自动移除广告、导航和样板内容
- 元数据提取(标题、描述、语言)
- JavaScript 渲染处理动态内容
- 自动处理反爬虫措施
返回针对 LLM 消费优化的 Markdown,最小噪音,最大信号。
Request Body
- url (string) *required: 要蒸馏的网页 URL
- timeout (number): 请求超时时间(毫秒),默认 30000,最大 60000
- waitFor (number): 页面加载后等待动态内容渲染的时间(毫秒),然后再提取内容
- includeTags (string[]): 仅包含这些 HTML 标签中的内容(如 ['article', 'main', 'div.content'])
- excludeTags (string[]): 排除这些 HTML 标签中的内容(如 ['nav', 'footer', 'aside'])
- headers (object): 随请求发送的自定义 HTTP 头
Response (200): 成功响应
- success (boolean):
- data (object):
- url (string): 被蒸馏的 URL
- markdown (string): 从页面提取的干净 Markdown 内容
- html (string): 原始 HTML 内容(可选,仅在请求时返回)
- metadata (object):
- title (string): 从 <title> 标签或 Open Graph 提取的页面标题
- description (string): Meta 描述或摘要
- language (string): 检测到的语言代码(ISO 639-1)
- author (string): 文章作者(如果有)
- publishedDate (string): 发布日期(如果有)
- image (string): 来自 Open Graph 或 Twitter Card 的特色图片 URL
- sourceURL (string): 原始 URL(可能因重定向与请求 URL 不同)
- statusCode (integer): 响应的 HTTP 状态码
- contentLength (integer): Markdown 内容的字符长度
- links (object[]): 内容中发现的链接
Example Request
curl 'https://open.thunderbit.com/v1/distill' \
--header 'Authorization: Bearer YOUR_SECRET_TOKEN' \
--header 'Content-Type: application/json' \
--data '{"url":"https://example.com/article","timeout":30000,"waitFor":2000,"includeTags":["article","main"],"excludeTags":["nav","footer","aside"],"headers":{"User-Agent":"MyBot/1.0"}}'Example Response
{
"success": true,
"data": {
"url": "https://example.com/article",
"markdown": "# Article Title\n\nContent...",
"html": "<article>...</article>",
"metadata": {
"title": "string",
"description": "string",
"language": "string",
"author": "string",
"publishedDate": "2025-01-01T00:00:00Z",
"image": "string",
"sourceURL": "string",
"statusCode": 1,
"contentLength": 1
},
"links": [
{
"text": "string",
"href": "string"
}
]
}
}