Skip to content

Google AI Mode 实时 SERP HTML

POST /v3/serp/google/ai_mode/live/html

本接口使用 POST 方法,请求路径为:

/v3/serp/wp/v2/live/html

实时 SERP HTML 接口根据指定的、搜索引擎和地理位置,返回搜索结果页面的原始 HTML。平台限流以认证说明中的 30/60/120 次/分钟规则为准。

计费说明

每次成功提交请求都会产生费用。扣费以响应头 X-SeerMarTech-Charge-CNY 为准。

所有 POST 数据使用 UTF-8 编码的 JSON 格式,并以 JSON 数组提交:

json
[
  {
    "keyword": "albert einstein",
    "language_code": "en",
    "location_code": 2840
  }
]

请求参数

参数类型说明
keywordstring查询。填。最多 700 个字符。接口会对 %## 编码进行解码,并将加号 + 解码为空格。如果中需要使用百分号 %,请编码为 %25;如果需要使用加号 +,请编码为 %2B
location_namestring搜索引擎地理位置的完整名称。当未指定 location_codelocation_coordinate 时填。使用该参数后,无需再提交另外两个位置参数。可通过 /v3/serp/wp/locations 获取可用位置名称。示例:London,England,United Kingdom
location_codeinteger搜索引擎地理位置代码。当未指定 location_namelocation_coordinate 时填。使用该参数后,无需再提交另外两个位置参数。可通过 /v3/serp/wp/locations 获取可用位置代码。示例:2840
location_coordinatestring地理位置 GPS 坐标。当未指定 location_namelocation_code 时填。格式为 纬度,经度,半径。纬度和经度最多支持 7 位小数;半径最小值为 199.9 米,最大值为 199999 米。示例:53.476225,-2.243572,200
language_namestring搜索引擎语言的完整名称。当未指定 language_code 时填。使用该参数后,无需再提交 language_code。可通过 /v3/serp/google/ai_mode/languages 获取可用语言名称。
language_codestring搜索引擎语言代码。当未指定 language_name 时填。使用该参数后,无需再提交 language_name。可通过 /v3/serp/google/ai_mode/languages 获取可用语言代码。
devicestring设备类型,可选值为 desktopmobile。默认值为 desktop
osstring设备操作系统。当 devicedesktop 时,可选值为 windowsmacos,默认值为 windows;当 devicemobile 时,可选值为 androidios,默认值为 android
tagstring自定义任务标识,可选,最多 255 个字符。可用于识别任务并与响应结果进行匹。提交的值会原样返回在响应的 data 对象中。

> location_namelocation_codelocation_coordinate 三只能选择一个。
> language_namelanguage_code 二只能选择一个。

请求示例

cURL

bash
curl --location --request POST \
  "https://api.seermartech.cn/v3/serp/wp/v2/live/html" \
  --header "Authorization: Bearer smt_live_YOUR_KEY" \
  --header "Content-Type: application/json" \
  --data-raw '[
    {
      "language_code": "en",
      "location_code": 2840,
      "keyword": "albert einstein",
      "device": "desktop",
      "os": "windows",
      "tag": "tag2"
    }
  ]'

Python

python
import requests

url = "https://api.seermartech.cn/v3/serp/wp/v2/live/html"

headers = {
    "Authorization": "Bearer smt_live_YOUR_KEY",
    "Content-Type": "application/json",
}

# 每次请求只能提交一个任务
payload = [
    {
        "language_code": "en",
        "location_code": 2840,
        "keyword": "albert einstein",
        "device": "desktop",
        "os": "windows",
        "tag": "tag2",
    }
]

response = requests.post(url, headers=headers, json=payload)
result = response.json()

if result.get("status_code") == 20000:
    print(result)
else:
    print(
        "请求失败,状态码:%s,信息:%s"
        % (result.get("status_code"), result.get("status_message"))
    )

TypeScript

typescript
import axios from "axios";

const response = await axios.post(
  "https://api.seermartech.cn/v3/serp/wp/v2/live/html",
  [
    {
      language_code: "en",
      location_code: 2840,
      keyword: "albert einstein",
      device: "desktop",
      os: "windows",
      tag: "tag2",
    },
  ],
  {
    headers: {
      Authorization: "Bearer smt_live_YOUR_KEY",
      "Content-Type": "application/json",
    },
  }
);

const result = response.data;

if (result.status_code === 20000) {
  console.log(result);
} else {
  console.error(
    `请求失败,状态码:${result.status_code},信息:${result.status_message}`
  );
}

响应结构

接口返回 JSON 对象 tasks 数组。每个任务对应一个提交的请求。

顶层响应字段

字段类型说明
versionstring当前 API 版本。
status_codeinteger顶层响应状态码。20000 表示请求成功。完整状态码列表请参考错误码文档。
status_messagestring顶层响应说明。
timestring请求执行耗时,例如 7.7543 sec.
costfloat平台原始 USD 成本兼容字段;人民币实扣以 X-SeerMarTech-Charge-CNY 为准。
tasks_countintegertasks 数组中的任务总数。
tasks_errorintegertasks 数组中返回错误的任务数量。
tasksarray任务结果数组。

tasks 任务字段

字段类型说明
idstring任务唯一标识,采用 UUID 格式。
status_codeinteger任务状态码,通常位于 1000060000 范围。
status_messagestring任务状态说明。
timestring任务执行耗时。
costfloat平台原始 USD 成本兼容字段;人民币实扣以 X-SeerMarTech-Charge-CNY 为准。
result_countintegerresult 数组中的数量。
patharray请求 URL 路径信息。
dataobject请求中提交的任务参数。
resultarraySERP 结果数组。

result 结果字段

字段类型说明
keywordstring请求中的。返回时已对 %## 编码进行解码,加号 + 会被解码为空格。
typestring请求中的搜索引擎类型。
se_domainstring请求中的搜索引擎域名。
location_codeinteger地理位置代码。
language_codestring语言代码。
datetimestring获取结果的日期和时间,使用 UTC 格式:yyyy-mm-dd hh-mm-ss +00:00。示例:2019-11-15 12:57:46 +00:00
items_countintegeritems 数组中返回的结果数量。
itemsarraySERP 中识别到的搜索结果。
pageinteger返回的 HTML 页面序号。
datestringHTML 页面扫描时间,格式为 年-月-日 时:分:秒 UTC 时差。示例:2019-11-15 12:57:46 +00:00
htmlstring搜索结果页面的原始 HTML。

响应示例

json
{
  "version": "0.1.20200130",
  "status_code": 20000,
  "status_message": "Ok.",
  "time": "7.7543 sec.",
  "cost": 0.003,
  "tasks_count": 1,
  "tasks_error": 0,
  "tasks": [
    {
      "id": "12345678-1234-1234-1234-123456789012",
      "status_code": 20000,
      "status_message": "Ok.",
      "time": "7.5000 sec.",
      "cost": 0.003,
      "result_count": 1,
      "path": [
        "v3",
        "serp",
        "wp",
        "v2",
        "live",
        "html"
      ],
      "data": {
        "api": "serp",
        "function": "live",
        "se": "wp",
        "se_type": "v2",
        "language_code": "en",
        "location_code": "2840",
        "keyword": "albert einstein",
        "tag": "tag2",
        "device": "desktop",
        "os": "windows"
      },
      "result": [
        {
          "keyword": "albert einstein",
          "type": "v2",
          "se_domain": "google.com",
          "location_code": 2840,
          "language_code": "en",
          "datetime": "2019-11-15 12:57:46 +00:00",
          "items_count": 1,
          "items": [],
          "page": 1,
          "date": "2019-11-15 12:57:46 +00:00",
          "html": "<html>...</html>"
        }
      ]
    }
  ]
}

错误处理

建议在客户端对以下字段进行检查:

  1. 检查顶层 status_code 是否为 20000
  2. 检查 tasks_error 是否大于 0
  3. 逐项检查 tasks[].status_codetasks[].status_message
  4. 对网络时、鉴权失败、参数缺失和平台搜索请求异常进行重试或记录。

实用场景

  • 采集指定的原始 SERP HTML,还原搜索结果页面结构,为自建解析器、页面渲染和结果抽取流程提供原始数据。
  • 对比不同国家、城市和语言下的搜索页面,识别本地化 SERP 差异,支持 SEO 和区域策略制定。
  • 分别抓取桌面端与移动端结果页面,分析设备差异对搜索展现的影响,移动端 SEO 优化。
  • 按任务标签追踪批量采集结果,将 HTML 页面与、项目或客户,提升 SEO 监测任务的可追溯性。
  • 定期保存搜索页面快,对比不同时间点的 SERP 变化,为竞争对手监控、排名波动分析和搜索功能研究提供依据。

统一入口:官网 · LLM API · 控制台