主题
实时 SERP HTML(WordPress)
GET /v3/appendix/errors
POST /v3/serp/wp/v2/live/html
本接口用于获取指定、搜索位置、语言和设备条件下的实时搜索结果原始 HTML 页面。每次请求支持提交 1 个任务,请求体为 UTF-8 编码的 JSON 数组。
平台限流以认证说明中的 30/60/120 次/分钟规则为准。结果深度默认最多返回 10 条;当 depth 大于 10 且搜索引擎返回更多结果时,可能产生额外扣费。扣费以响应头 X-SeerMarTech-Charge-CNY 为准。
请求地址
text
https://api.seermartech.cn/v3/serp/wp/v2/live/html认证方式
在请求头中使用 Bearer Token:
http
Authorization: Bearer smt_live_YOUR_KEY
Content-Type: application/json请求参数
主要参数
| 字段 | 类型 | 填 | 说明 |
|---|---|---|---|
keyword | string | 是 | 查询,最长 700 个字符。请求中的 %## 会被解码,+ 会被解码为空格。如需查询字面量 %,请写为 %25;如需查询字面量 +,请写为 %2B。 |
location_code | integer | 条件填 | 搜索位置编码。未提供 location_name 和 location_coordinate 时填。使用该字段后,无需提供另外两个位置字段。示例:2840。可通过 /v3/serp/wp/locations 获取可用位置列表。 |
language_code | string | 条件填 | 搜索语言编码。未提供 language_name 时填。使用该字段后,无需提供 language_name。示例:en。可通过 /v3/serp/wp/languages 获取可用语言列表。 |
depth | integer | 否 | SERP 解析深度,即返回结果数量。默认值:10;最大值:200。深度 10 时,如返回更多结果,可能产生额外扣费。 |
device | string | 否 | 设备类型,可选 desktop 或 mobile。默认值:desktop。 |
可选参数
| 字段 | 类型 | 说明 |
|---|---|---|
location_name | string | 搜索位置称。未提供 location_code 和 location_coordinate 时填。示例:London,England,United Kingdom。可通过 /v3/serp/wp/locations 查询。 |
language_name | string | 搜索语言称。未提供 language_code 时填。示例:English。可通过 /v3/serp/wp/languages 查询。 |
os | string | 设备操作系统。device=desktop 时可选 windows、macos,默认 windows;device=mobile 时可选 android、ios,默认 android。 |
tag | string | 自定义任务标识,最长 255 个字符。响应中可通过 tasks[].data.tag 获取该值,用于请求和结果。 |
stop_crawl_on_match | array | 命中指定目标时停止继续抓取。最多可传 10 个目标对象。返回结果将目标命中所在页面及此前结果。达到停止条件前抓取的每个 SERP 页面均可能计费。 |
max_crawl_pages | integer | 最大抓取结果页数。默认值:1;最大值:100。该参数与 depth合控制抓取范围。 |
search_param | string | 附加搜索查询参数。 |
url | string | 搜索查询的完整直达 URL。平台会尝试从 URL 解析查询条件,但该方式处理复杂,且 URL 中准确指定语言和位置,通常建议优使用结构化参数。 |
location_coordinate | string | GPS 坐标,格式为 "latitude,longitude";经纬度最多支持 7 位小数。未提供 location_code 和 location_name 时填。示例:53.476225,-2.243572。 |
stop_crawl_on_match 目标对象
当使用 stop_crawl_on_match 时,数组中的每个对象均需以下字段:
| 字段 | 类型 | 填 | 说明 |
|---|---|---|---|
match_type | string | 是 | 匹方式:domain 表示指定域名或子域名;with_subdomains 表示主域名及子域名;wildcard 表示通符模式。 |
match_value | string | 是 | 要匹的域名、子域名或通符规则。域名和子域名不得 http:// 或 https:// 协议前缀。示例:example.com、/blog/post-*。 |
请求示例
以下示例查询英文环境、美国位置下的 albert einstein,并返回桌面端结果 HTML。
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 '[
{
"keyword": "albert einstein",
"location_code": 2840,
"language_code": "en",
"device": "desktop",
"depth": 10,
"tag": "wp-html-demo"
}
]'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",
}
# 实时接口每次支持一个任务,仍需使用 JSON 数组裹
payload = [
{
"keyword": "albert einstein",
"location_code": 2840,
"language_code": "en",
"device": "desktop",
"depth": 10,
"tag": "wp-html-demo",
}
]
response = requests.post(url, headers=headers, json=payload, timeout=60)
response.raise_for_status()
result = response.json()
print(result)
# 实人民币扣费以响应头为准
charge_cny = response.headers.get("X-SeerMarTech-Charge-CNY")
print("本次扣费(CNY):", charge_cny)TypeScript
typescript
const url = "https://api.seermartech.cn/v3/serp/wp/v2/live/html";
// 实时接口每次提交一个任务,请求体是 JSON 数组
const payload = [
{
keyword: "albert einstein",
location_code: 2840,
language_code: "en",
device: "desktop",
depth: 10,
tag: "wp-html-demo",
},
];
const response = await fetch(url, {
method: "POST",
headers: {
Authorization: "Bearer smt_live_YOUR_KEY",
"Content-Type": "application/json",
},
body: JSON.stringify(payload),
});
if (!response.ok) {
throw new Error(`请求失败:HTTP ${response.status}`);
}
const result = await response.json();
console.log(result);
// 实人民币扣费以响应头为准
console.log(
"本次扣费(CNY):",
response.headers.get("X-SeerMarTech-Charge-CNY")
);使用命中目标停止抓取
以下示例会持续抓取搜索结果页,直到结果中出现 example.com 主域名或任意子域名,最多抓取 10 页:
json
[
{
"keyword": "seo tools",
"location_code": 2840,
"language_code": "en",
"depth": 100,
"max_crawl_pages": 10,
"stop_crawl_on_match": [
{
"match_type": "with_subdomains",
"match_value": "example.com"
}
]
}
]响应说明
接口返回 JSON 对象 tasks 数组本次提交的任务及对应结果。
顶层字段
| 字段 | 类型 | 说明 |
|---|---|---|
version | string | 当前 API 版本。 |
status_code | integer | 局状态码。20000 通常表示请求成功。错误码请参考 /v3/appendix/errors。 |
status_message | string | 局状态说明。 |
time | string | 请求总执行耗时,单位为秒。 |
cost | float | 平台原始 USD 成本兼容字段;人民币实扣以 X-SeerMarTech-Charge-CNY 为准。 |
tasks_count | integer | tasks 数组中的任务数量。 |
tasks_error | integer | 返回错误的任务数量。 |
tasks | array | 任务结果数组。 |
tasks 任务字段
| 字段 | 类型 | 说明 |
|---|---|---|
id | string | 平台生成的唯一任务标识,采用 UUID 格式。 |
status_code | integer | 任务状态码,范围通常为 10000 至 60000。 |
status_message | string | 任务状态说明。 |
time | string | 任务执行耗时,单位为秒。 |
cost | float | 平台原始 USD 成本兼容字段;人民币实扣以 X-SeerMarTech-Charge-CNY 为准。 |
result_count | integer | result 数组中的结果数量。 |
path | array | 请求 URL 路径信息。 |
data | object | 回显提交任务时指定的请求参数 keyword、位置、语言、设备和 tag 等。 |
result | array | 搜索结果页数据数组。 |
result 结果字段
| 字段 | 类型 | 说明 |
|---|---|---|
keyword | string | 请求中的。响应中 %## 会被解码,+ 会被解码为空格。 |
type | string | 请求中的搜索引擎类型。 |
se_domain | string | 搜索引擎域名。 |
location_code | integer | 请求使用的位置编码。 |
language_code | string | 请求使用的语言编码。 |
datetime | string | 获取结果的 UTC 时间,格式为 yyyy-mm-dd hh:mm:ss +00:00。 |
items_count | integer | items 数组中的结果数量。 |
items | array | SERP 中识别到的搜索结果。 |
page | integer | 返回的 HTML 搜索结果页序号。 |
date | string | HTML 页面抓取时间,使用 UTC 时间格式。 |
html | string | 搜索结果页的原始 HTML。 |
响应示例
json
{
"version": "0.1.20200203",
"status_code": 20000,
"status_message": "Ok.",
"time": "4.7397 sec.",
"cost": 0.003,
"tasks_count": 1,
"tasks_error": 0,
"tasks": [
{
"id": "00000000-0000-0000-0000-000000000000",
"status_code": 20000,
"status_message": "Ok.",
"time": "4.7397 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": "wp-html-demo",
"device": "desktop",
"os": "windows"
},
"result": [
{
"keyword": "albert einstein",
"type": "wp",
"se_domain": "example.search.engine",
"location_code": 2840,
"language_code": "en",
"datetime": "2019-11-15 12:57:46 +00:00",
"items_count": 10,
"items": [],
"page": 1,
"date": "2019-11-15 12:57:46 +00:00",
"html": "<html>...</html>"
}
]
}
]
}错误处理
建议同时检查 HTTP 状态码、顶层 status_code 以及各任务的 tasks[].status_code。
- HTTP 请求失败时,优处理网络、认证、限流或请求格式问题。
- 顶层
status_code非20000时,表示请求整体未成功处理。 tasks_error大于0时,应遍历tasks,读取每个任务的status_code和status_message。- 错误码与状态说明请参考
/v3/appendix/errors。 - 对限流、临时服务异常等可重试错误,建议采用指数退避策略重试。
实用场景
- 存档搜索结果页面:保存指定在特定国家、语言和设备下的原始 HTML,为 SEO 审计、竞品取证和历史排名回溯提供页面级证据。
- 解析自然搜索版位:从
html字段提取标题、链接、摘要及页面模块,构建自定义的排名监测系统。 - 追踪品牌或竞品出现位置:结合
stop_crawl_on_match在目标域名出现时停止抓取,降低深层 SERP 监测的无效抓取成本。 - 比对移动端与桌面端结果:分别指定
device=mobile与device=desktop,识别不同设备下的排名差异、页面布局和可见变化。 - 验证地域化搜索呈现:通过
location_code或location_coordinate获取不同城市、国家的结果 HTML,评估本地化 SEO 策略的覆盖效果。