MarkUDown

Smart Extract API — MarkUDown AI 网页提取 API 文档

POST/api/smart-extract

Smart Extract

三阶段引导式提取:先分析网站难度,再用 LLM 规划所需的交互,最后自动执行导航与提取。返回 Markdown 或结构化 JSON。

参数类型必填默认值描述
urlstring必填—要提取数据的页面或网站 URL。
goalstring必填—用自然语言描述要提取的内容。
hintsarray<string>可选[]可选的交互提示(例如 "点击加载更多按钮")。
schemaobject可选null结构化输出的字段定义,例如 {"title": "string", "price": "number"}。json_data 需要它。
output_formatstring可选"markdown""markdown" 或 "json"。使用 "json" 并提供 schema 时,记录也会在 json_data 中返回。
max_pagesinteger可选20提取过程中最多遍历的页面数。
timeoutinteger可选60每个页面的超时时间(秒)。
callback_urlstring可选null任务完成时接收结果(POST)的 webhook URL。

请求

{
  "url": "https://books.toscrape.com",
  "goal": "Extract all books with title, price and rating",
  "output_format": "json",
  "schema": {
    "title": "string",
    "price": "string",
    "rating": "string"
  },
  "max_pages": 10
}

响应

{
  "success": true,
  "id": "job_abc123",
  "url": "/api/smart-extract/job_abc123"
}

// Poll GET /api/smart-extract/{id}
{
  "success": true,
  "id": "job_abc123",
  "status": "completed",
  "data": {
    "success": true,
    "data": {
      "url": "https://books.toscrape.com",
      "markdown": "# Books\n\n...",
      "json_data": [
        { "title": "A Light in the Attic", "price": "£51.77", "rating": "Three" }
      ],
      "metadata": {
        "layer_used": "playwright",
        "pages_traversed": 4,
        "records_extracted": 80,
        "difficulty": "medium",
        "actions_executed": 3,
        "planner_reasoning": "...",
        "duration_ms": 38200
      }
    },
    "processing_time_ms": 38400
  }
}