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"
}
]
}
}