跳转到主要内容
POST https://api.acedata.cloud/webextrator/extract WebExtrator 智能抽取 API 把一个 URL 转换成类型化的结构化结果 —— 文章、商品、 食谱、视频、讨论、招聘等,同时附带清洗后的 Markdown 与纯文本。当你想要”干净的结 构化数据”而不是原始 HTML 时,这是该用的接口。 底层是一条三层流水线:
  1. schema.org JSON-LD 映射器 —— 确定性、零 LLM 成本。覆盖 Wikipedia / BestBuy / AllRecipes / YouTube / 大部分新闻 / 大部分商品页。
  2. 类型化 LLM 抽取 —— 仅在 schema.org 未命中时触发。按页面类型选 Schema, Zod 严格校验。
  3. Readability + Markdown 兜底 —— 始终运行,补齐前两层没填的顶层字段。
URL 重复请求会被 Redis 结果缓存接住,<1 ms 返回。

申请流程

要使用 WebExtrator 服务页,首先到 Ace Data Cloud 控制台 获取您的 API Token,留作备用。 如果你尚未登录或注册,会自动跳转到登录页面邀请你注册和登录,完成后会自动返回当前页面。 一个 API Token 即可调用平台所有服务,无需为每个服务单独申请。 首次申请会赠送免费额度,可免费体验;额度不足时可在 控制台 充值通用余额。
📘 完整文档:WebExtrator 服务页 →

鉴权

请求参数

Extract 接受所有Render API 的参数 (urluser_agenttimeoutwait_untildelaywait_for_selectorblock_resourcesheaderscookiescallback_urlbypass_cachecache_ttl_secondsmode),外加两个 Extract 专属字段:
当页面自带 schema.org JSON-LD 时,enable_llm 无效 —— 确定性映射器直接出结果, 永远不会浪费 LLM 调用。你白嫖到类型化结果。

同步响应

顶层字段

data.structured 子字段

schema.org 映射器覆盖范围

按优先级排序(命中即作为 structured.schemaOrg.primary): 映射器处理:
  • @graph 容器(递归展开);
  • @type 数组(如 ["Recipe", "NewsArticle"] —— 两个都识别,按优先级取胜);
  • http://schema.org/ 前缀变体;
  • 嵌套 OfferAggregateOffer(后者读 lowPrice);
  • 相对图像 URL(按 finalUrl 解析为绝对)。

LLM 类型化 Schema

enable_llm: true schema.org 没有 primary 时,抽取器按 URL 启发式 (或 expected_type 提示)选下面之一的 Zod Schema 校验模型输出: LLM 成功时还会向顶层字段做”last-resort”回填:
  • articledescription / byline / publishedAt / language
  • productdescription
  • discussiondescription(= body 前 280 字)/ byline(= author)/ publishedAt(= postedAt)
  • recipedescription / byline(= author)
  • videodescription / byline(= channel)/ publishedAt(= uploadDate)
  • jobdescription / byline(= company)/ publishedAt(= datePosted)
回填只在确定性数据源没填对应字段时触发 —— LLM 始终是最后一道兜底。

缓存

相同请求会被哈希到同一个 Redis Key: webextrator:cache:extract:<sha256(canonical-json)>。缓存 Key 忽略 modebypass_cachecache_ttl_seconds(这是操作开关,不影响响应)。cookies / headers 分桶缓存。 命中缓存的响应会带上 data.cached: truedata.cacheStoredAt: <unix-ms>

异步模式与回调

设置 mode: "async" 进入异步模式。平台立即返回(HTTP 202):
任务完成时把完整 envelope POST 到你的 callback_url(如果配置了)。也可以事 后通过 /webextrator/tasks 主动查询。

示例

1. Wikipedia 文章(schema.org 命中,不需要 LLM)

data.structured.schemaOrg.primary 关键字段:

2. BestBuy 商品页(schema.org 命中)

schema.org 抽出:

3. AllRecipes 食谱页(含营养与步骤)

schema.org 抽出:

4. HN 讨论页(无 JSON-LD —— 需要启用 LLM)

data.structured.llm.data
顶层字段也被回填:byline = "alice"publishedAt = "..."

5. Amazon 商品页(Amazon 无 JSON-LD —— 需要启用 LLM)

data.structured.llm.data(类型化 product):

Python (requests)

Node.js (fetch)

提示与坑

  • 能传 expected_type 就传。 免费提示,跳过启发式判断,对 URL 模式不在 内置列表里的页面尤其有用。
  • enable_llm: true 在 schema.org 命中的页面上是免费的。 LLM 只在 schema.org 没有 primary 时才被调用,所以默认开着也很安全。
  • 调试时先看 rawSignals.hasJsonLd 如果是 truestructured.schemaOrg.primarynull,说明页面用了我们映射器还没覆盖的 @type —— 提个 issue,我们加。
  • structured.llmError 是信息性的。 请求依然成功,启发式结果依然返回。看 llmError.error 来定位原因(超时、JSON 解析失败、Zod 校验失败)。
  • 非文章页的 links[] 不会做相关性排序。 仅按”上限 100 条 + 过滤无效协议” 尽力清洗。
  • 缓存命中也计费。 缓存是为延迟和保护浏览器池,不是为省钱。