LogoLexmount 文档
LogoLexmount 文档
首页

介绍

使用指南OpenClaw 接入 Lexmount 说明Codex Skill 接入 Lexmount 说明
WebFetch API快速开始
All-in-One ExtractDump DOM常见错误
X (Twitter)
WebFetch API参考

Dump DOM

获取 HTML、检查渲染结果,并复用 DOM 快照。

POST /v1/dom/dump

当你需要直接拿到抓取后的 HTML、检查页面渲染结果、或者希望在后续提取请求中复用 DOM 快照时,使用这个接口。

鉴权说明

  • 当前接口处于内测阶段
  • 外部调用时,请求需要带 X-API-Key
  • 请联系管理员获取 API key

请求体

{
  "url": "https://example.com",
  "options": {
    "engine_preference": "lightmount_dcl",
    "timeout_ms": 30000,
    "filter_scripts_styles": false
  }
}

字段说明

字段类型必填说明
urlstring是要抓取的页面 URL
options.engine_preferencestring否指定引擎,默认 auto
options.timeout_msint否请求超时
options.filter_scripts_stylesbool否是否在返回和落盘前移除 script 和 style

支持的 engine_preference:

  • auto
  • http
  • chrome
  • chrome_cdp
  • lightmount_lite
  • lightmount_dcl
  • lightmount_domstable

基础示例

API_KEY='<your-api-key>'

curl -sS -X POST https://webfetch.lexmount.com/v1/dom/dump \
  -H 'content-type: application/json' \
  -H "X-API-Key: $API_KEY" \
  -d '{
    "url": "https://example.com",
    "options": {
      "engine_preference": "lightmount_dcl",
      "timeout_ms": 30000
    }
  }' \
  | jq '{final_url, engine, dom_id, dump_path, html_len:(.html|length)}'

响应字段

常用返回字段:

  • url
  • final_url
  • status_code
  • fetched_at
  • engine
  • dom_id
  • dump_path
  • html
  • debug

过滤 script / style

curl -sS -X POST https://webfetch.lexmount.com/v1/dom/dump \
  -H 'content-type: application/json' \
  -H "X-API-Key: $API_KEY" \
  -d '{
    "url": "https://example.com",
    "options": {
      "engine_preference": "lightmount_dcl",
      "filter_scripts_styles": true
    }
  }' \
  | jq '{dom_id, has_script:(.html|test("<script"; "i")), has_style:(.html|test("<style"; "i"))}'

这个模式适合拿到更干净的 DOM 用于检查和模板调试,但不要把它当成浏览器原始快照的完全等价物。

复用 dom_id

先抓取快照,再把 dom_id 交给 /v1/extract:

DOM_ID="$(curl -sS -X POST https://webfetch.lexmount.com/v1/dom/dump \
  -H 'content-type: application/json' \
  -H "X-API-Key: $API_KEY" \
  -d '{"url":"https://example.com","options":{"engine_preference":"lightmount_dcl"}}' \
  | jq -r '.dom_id')"

curl -sS -X POST https://webfetch.lexmount.com/v1/extract \
  -H 'content-type: application/json' \
  -H "X-API-Key: $API_KEY" \
  -d "{\"extract\":{\"dom_id\":\"$DOM_ID\"},\"trace\":{\"include_steps\":false,\"include_raw_dom\":false}}" \
  | jq '{title:.result.title, engine:.result.engine, template_id:.result.template_id, dom_id:.metadata.dom_id}'

如果要排查失败原因,见 Common Errors。

All-in-One Extract

POST /v1/extract 的完整请求与响应参考。

常见错误

WebFetch 接入时常见的 HTTP 和 API 失败场景。

目录

鉴权说明
请求体
字段说明
基础示例
响应字段
过滤 script / style
复用 dom_id