跳转到主要内容
POST
/
extract
利用 LLM 从页面提取结构化数据
curl --request POST \
  --url https://api.firecrawl.dev/v2/extract \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "urls": [
    "<string>"
  ],
  "prompt": "<string>",
  "schema": {},
  "enableWebSearch": false,
  "ignoreSitemap": false,
  "includeSubdomains": true,
  "showSources": false,
  "scrapeOptions": {
    "formats": [
      "markdown"
    ],
    "onlyMainContent": true,
    "includeTags": [
      "<string>"
    ],
    "excludeTags": [
      "<string>"
    ],
    "maxAge": 172800000,
    "headers": {},
    "waitFor": 0,
    "mobile": false,
    "skipTlsVerification": true,
    "timeout": 123,
    "parsers": [
      "pdf"
    ],
    "actions": [
      {
        "type": "wait",
        "milliseconds": 2,
        "selector": "#my-element"
      }
    ],
    "location": {
      "country": "US",
      "languages": [
        "en-US"
      ]
    },
    "removeBase64Images": true,
    "blockAds": true,
    "proxy": "auto",
    "storeInCache": true
  },
  "ignoreInvalidURLs": true
}
'
{
  "success": true,
  "id": "<string>",
  "invalidURLs": [
    "<string>"
  ]
}

授权

Authorization
string
header
必填

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

请求体

application/json
urls
string<uri>[]
必填

要从中提取数据的 URL。URL 应为 glob 格式。

prompt
string

用于引导提取过程的提示词

schema
object

用于定义提取后数据结构的 Schema。必须符合 JSON Schema 标准。

为 true 时,提取过程将通过 Web 搜索获取更多数据

ignoreSitemap
boolean
默认值:false

如果为 true,则在网站扫描过程中会忽略 sitemap.xml 文件

includeSubdomains
boolean
默认值:true

设为 true 时,也会扫描所提供 URL 的子域名

showSources
boolean
默认值:false

当为 true 时,用于提取数据的来源将作为 sources 键包含在响应中

scrapeOptions
object
ignoreInvalidURLs
boolean
默认值:true

如果在 urls 数组中指定了无效的 URL,这些 URL 将被忽略。请求不会因此整体失败,系统会改为使用剩余的有效 URL 执行提取操作,并在响应的 invalidURLs 字段中返回这些无效的 URL。

响应

提取成功

success
boolean
id
string
invalidURLs
string[] | null

如果 ignoreInvalidURLs 为 true,则该字段将是一个数组,包含请求中指定的无效 URL。若没有无效 URL,则该数组为空。如果 ignoreInvalidURLs 为 false,则该字段为 undefined。