主题
SERP 实时 HTML
本接口通过实时抓取,返回指定、搜索引擎、语言和地理位置对应的搜索结果页面原始 HTML。
请求方法与路径:POST /v3/serp/wp/v2/live/html
完整请求地址:
text
https://api.seermartech.cn/v3/serp/wp/v2/live/html本接口每次请求只能提交一个任务。所有 POST 数据使用 UTF-8 编码的 JSON 格式,并放在 JSON 数组中。平台限流以认证说明中的 30/60/120 次/分钟规则为准。
> 实扣费以响应头 X-SeerMarTech-Charge-CNY 为准。
请求参数
###填及主要参数
| 参数 | 类型 | 说明 |
|---|---|---|
keyword | string | **填。**查询,最长 700 个字符。参数中的 %## 编码会被解码,字符 + 会被解码为空格。如果中需要使用 %,请写为 %25;需要使用 +,请写为 %2B。如果 allinanchor:、allintext:、allintitle:、allinurl:、cache:、define:、filetype:、id:、inanchor:、info:、intext:、intitle:、inurl:、link:、related: 或 site: 等高级搜索操作符,单任务费用将按 5 倍计算。 |
location_code | integer | 搜索引擎位置代码。当未指定 location_name 或 location_coordinate 时填。使用此参数后,无需再指定位置参数。可通过 /v3/serp/google/locations 获取可用位置代码。例如:2840。 |
language_code | string | 搜索引擎语言代码。当未指定 language_name 时填。使用此参数后,无需再指定 language_name。可通过 /v3/serp/google/languages 获取可用语言代码。例如:en。 |
depth | integer | 解析深度,即需要返回的 SERP 结果数量。默认值为 10,最大值为 200。每组最多 10 条结果按一组 SERP 计费;当搜索引擎返回 10 条结果时,设置更大的 depth 可能产生额外费用。 |
device | string | 设备类型。可选值:desktop、mobile。默认值:desktop。 |
load_async_ai_overview | boolean | 是否加载异步生成的 AI Overview。设为 true 时,即使 AI Overview 异步加载,也会尝试获取对应项目;设为 false 时返回缓存中的 AI Overview。默认值:false。启用后每次请求增加约 ¥0.0144 参考费用;当该字段缺失或设置为 false 时,不收取此项附加费用。 |
参数
| 参数 | 类型 | 说明 |
|---|---|---|
location_name | string | 搜索引擎位置的完整名称。当未指定 location_code 或 location_coordinate 时填。使用此参数后,无需再指定位置参数。例如:London,England,United Kingdom。 |
language_name | string | 搜索引擎语言的完整名称。当未指定 language_code 时填。使用此参数后,无需再指定 language_code。例如:English。 |
os | string | 设备操作系统。当 device 为 desktop 时,可选值为 windows、macos,默认值为 windows;当 device 为 mobile 时,可选值为 android、ios,默认值为 android。 |
tag | string | 用户自定义任务标识,最长 255 个字符。可用于任务与结果,提交的值会原样返回在响应的 data 对象中。 |
stop_crawl_on_match | array | 用于提前停止抓取的目标数组。每个目标对象 match_type 和 match_value,最多可设置 10 个目标。设置后,响应将截至目标匹结果为止的 SERP 数据(匹结果)。每抓取一组符合条件的 SERP 均会计费。 |
match_type | string | 目标匹类型。启用 stop_crawl_on_match 时填。可选值:domain(匹指定域名或子域名)、with_subdomains(匹主域名及子域名)、wildcard(通符匹)。 |
match_value | string | 目标域名、子域名或通符值。启用 stop_crawl_on_match 时填。域名或子域名不得协议头。例如:example.com、/blog/post-*。 |
max_crawl_pages | integer | 最多抓取的搜索结果页数,最大值为 100。每抓取一页都会计费,每页最多 10 条自然搜索结果。该参数与 depth合使用。 |
search_param | string | 搜索查询的附加参数。以下参数不受支持,若指定将被自动移除:lr、cr、as_qdr、as_sitesearch、as_occt、as_filetype。 |
expand_ai_overview | boolean | 是否展开 ai_overview 项目。默认值为 false。 |
url | string | 搜索查询的完整 URL。接口会从 URL 中解析所需参数。该方式处理复杂,且在 URL 中指定准确的语言和位置,通常不建议使用。例如:https://www.google.co.uk/search?q=%20rank%20tracker%20api&hl=en&gl=GB&uule=w+CAIQIFISCXXeIa8LoNhHEZkq1d1aOpZS。以下参数不受支持,若出现在 URL 中将被自动移除:lr、cr、as_qdr、as_sitesearch、as_occt、as_filetype。 |
location_coordinate | string | 位置 GPS 坐标,格式为 "纬度,经度,半径"。纬度和经度最多支持 7 位小数;半径最小值为 199,最大值为 199999。例如:53.476225,-2.243572,200。当未指定 location_name 或 location_code 时填。 |
se_domain | string | 搜索引擎域名。接口会根据位置和语言自动选择域名,也可以手动指定,例如:google.co.uk、google.com.au、google.de。 |
target_search_mode | string | 多目标匹模式。只有启用 stop_crawl_on_match 时才生效。可选值:all(所有目标均找到后停止)、any(任一目标找到后停止)。默认值为 any。 |
find_targets_in | array | 指定在哪些 SERP素中查找目标。只有启用 stop_crawl_on_match 时才生效。未指定时,会检查所有 url 和 domain 字段的一级 SERP素。可选值:organic、paid、local_pack、featured_snippet、events、google_flights、images、jobs、knowledge_graph、local_service、map、scholarly_articles、third_party_reviews、twitter。不能与 ignore_targets_in含相同类型。 |
ignore_targets_in | array | 指定查找目标时需要排除的 SERP素。只有启用 stop_crawl_on_match 时才生效。可选值与 find_targets_in 相同,且不能与相同类型。 |
请求示例
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"
}
]'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",
}
]
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",
},
],
{
headers: {
Authorization: "Bearer smt_live_YOUR_KEY",
"Content-Type": "application/json",
},
}
);
if (response.data.status_code === 20000) {
console.log(response.data);
} else {
console.error(
`请求失败,错误码:${response.data.status_code},错误信息:${response.data.status_message}`
);
}响应结构
接口返回 JSON 数据,顶层 tasks 任务数组。
顶层字段
| 字段 | 类型 | 说明 |
|---|---|---|
version | string | 当前 API 版本。 |
status_code | integer | 通用状态码。可参考错误码文档。 |
status_message | string | 通用状态信息。 |
time | string | 请求执行耗时,单位为秒。 |
cost | float | 平台原始 USD 成本兼容字段;人民币实扣以 X-SeerMarTech-Charge-CNY 为准。 |
tasks_count | integer | tasks 数组中的任务数量。 |
tasks_error | integer | tasks 数组中返回错误的任务数量。 |
tasks | array | 任务结果数组。 |
任务字段
| 字段 | 类型 | 说明 |
|---|---|---|
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 | 请求路径。 |
data | object | 请求中提交的任务参数。 |
result | array | SERP HTML 结果数组。 |
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。例如:2019-11-15 12:57:46 +00:00。 |
items_count | integer | items 数组中的结果数量。 |
items | array | 搜索结果数组。 |
page | integer | 返回的 HTML 页面序号。 |
date | string | HTML 页面扫描时间,格式为:年-月-日 时:分:UTC 时差:UTC 分差。例如:2019-11-15 12:57:46 +00:00。 |
html | string | 搜索结果页面的原始 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": "0708f9e7-1234-4567-8901-abcdef123456",
"status_code": 20000,
"status_message": "Ok.",
"time": "7.7543 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>"
}
]
}
]
}
]
}如需处理异常,请根据顶层或任务级别的 status_code 与 status_message 实现错误处理逻辑。
实用场景
- 抓取指定的实时 SERP 原始 HTML,复现用户看到的搜索页面并支持自定义解析。
- 对比桌面端与移动端 SERP 页面差异,识别移动搜索结果中的排名、展示模块和变化。
- 按国家、城市或 GPS 坐标采集本地化搜索结果,评估不同地区的 SEO 可见度。
- 使用
stop_crawl_on_match监测目标域名出现的结果位置,减少无效抓取并提升竞品排名跟踪效率。 - 获取 AI Overview 的实时搜索页面,分析生成式搜索结果对自然流量和 SERP 版位的影响。