主题
Google 新闻 SERP 实时 HTML 接口
POST /v3/serp/google/news/live/html
本接口使用 POST 方法,请求路径为:
POST https://api.seermartech.cn/v3/serp/google/news/live/html
实时 SERP HTML 接口根据指定的、搜索位置和语言,返回搜索结果页面的原始 HTML。默认抓取最多 10 条结果,适用于需要保留搜索页面原貌或自行解析 SERP 的场景。
> 原始示例中出现的 /v3/serp/wp/v2/live/html 为历史示例路径,不作为本接口的调用路径。请使用本文定义的 /v3/serp/google/news/live/html。
计费说明
每次请求按任务计费。
- 参考价约 ¥0.0216 / 个任务(按原始示例中的 0.003 美折算供参考)。
depth过 10 时,如果搜索引擎返回 10 条结果,可能产生额外费用。- 如果指定的
depth高于返回结果数量,未返回部分的费用会自动退还到账户余额。 - 如果
keyword中特定搜索操作符,单个任务的费用将按 5 倍计算。 - 实扣费以响应头
X-SeerMarTech-Charge-CNY为准。
所有 POST 请求体使用 UTF-8 编码的 JSON 数组格式。每次平台限流以认证说明中的 30/60/120 次/分钟规则为准。
请求头
http
Authorization: Bearer smt_live_YOUR_KEY
Content-Type: application/json请求参数
主要参数
| 参数 | 类型 | 填 | 说明 |
|---|---|---|---|
keyword | string | 是 | 搜索,最长 700 个字符。%## 编码会被解码,字符 + 会被解码为空格。若中需要使用 %,请写为 %25;需要使用 +,请写为 %2B。如果 allinanchor:、allintext:、allintitle:、allinurl:、define:、filetype:、id:、inanchor:、info:、intext:、intitle:、inurl:、link:、related: 或 site: 等操作符,单个任务费用将按 5 倍计算。 cache: 的查询不受支持,并会返回验证错误。 |
location_code | integer | 条件填 | 搜索引擎位置代码。未指定 location_name 或 location_coordinate 时填。使用此参数后,无需再指定另外两个位置参数。可通过位置接口获取可用代码:GET https://api.seermartech.cn/v3/serp/wp/locations。示例:2840。 |
language_code | string | 条件填 | 搜索引擎语言代码。未指定 language_name 时填。可通过语言接口获取可用代码:GET https://api.seermartech.cn/v3/serp/wp/languages。示例:en。 |
depth | integer | 否 | SERP 解析深度,即需要返回的结果数量。默认值为 10,最大值为 200。 |
location_name | string | 条件填 | 搜索引擎位置的完整名称。未指定 location_code 或 location_coordinate 时填。示例:London,England,United Kingdom。 |
language_name | string | 条件填 | 搜索引擎语言的完整名称。未指定 language_code 时填。示例:English。 |
os | string | 否 | 设备操作系统。本接口提供桌面端结果。可选值:windows、macos。默认值:windows。 |
tag | string | 否 | 自定义任务标识,最长 255 个字符。可用于任务与结果,响应中的 data 对象会返回该值。 |
max_crawl_pages | integer | 否 | 最多抓取的搜索结果页面数,最大值为 100。该参数与 depth合使用。 |
search_param | string | 否 | 搜索查询的附加参数。 |
url | string | 否 | 搜索查询的完整 URL。平台会从 URL 中解析参数。该方式处理复杂度较高,且在 URL 中明确指定语言和位置,通常不建议使用。 |
location_coordinate | string | 条件填 | 位置 GPS 坐标,格式为 纬度,经度,半径。纬度和经度最多 7 位小数;半径最小值为 199.9 米,最大值为 199999 米。示例:53.476225,-2.243572,200。 |
se_domain | string | 否 | 搜索引擎域名。平台会根据位置和语言自动选择域名,也可以手动指定,例如 google.co.uk、google.com.au、google.de。 |
位置与语言参数规则
以下参数三选一:
location_codelocation_namelocation_coordinate
以下参数二选一:
language_codelanguage_name
同一组参数中不建议同时传多个字段,否则可能导致参数冲突。
depth 与计费
平台按每个最多 10 条结果的 SERP 计费。将 depth 设置为大于 10 的值时,如果搜索引擎返回了更多结果,可能产生额外费用。
例如:
json
[
{
"keyword": "seo tools",
"location_code": 2840,
"language_code": "en",
"depth": 20
}
]请求示例
cURL
bash
curl --location --request POST \
"https://api.seermartech.cn/v3/serp/google/news/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"
}
]'Python
python
import requests
url = "https://api.seermartech.cn/v3/serp/google/news/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(
"请求失败,状态码:{},信息:{}".format(
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/google/news/live/html",
[
{
language_code: "en",
location_code: 2840,
keyword: "albert einstein",
},
],
{
headers: {
Authorization: "Bearer smt_live_YOUR_KEY",
"Content-Type": "application/json",
},
}
);
console.log(response.data);响应结构
接口返回 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 | 请求 URL 路径信息。 |
data | object | 创建任务时提交的参数。 |
result | array | SERP 结果数组。 |
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 页面扫描时间,格式为 yyyy-MM-dd HH:mm:ss +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": "11111111-2222-3333-4444-555555555555",
"status_code": 20000,
"status_message": "Ok.",
"time": "7.7543 sec.",
"cost": 0.003,
"result_count": 1,
"path": [
"v3",
"serp",
"google",
"news",
"live",
"html"
],
"data": {
"api": "serp",
"function": "live",
"se": "google",
"se_type": "news",
"language_name": "English",
"location_name": "United States",
"keyword": "albert einstein",
"tag": "tag1",
"device": "desktop",
"os": "windows"
},
"result": [
{
"keyword": "albert einstein",
"type": "news",
"se_domain": "google.com",
"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>"
}
]
}
]
}状态码与错误处理
20000表示请求或任务处理成功。- 状态码表示参数验证失败、任务处理失败或服务异常。
- 应用程序应同时检查顶层
status_code、tasks_error以及单个任务中的status_code。 - 发生错误时,应记录
status_code与status_message,并根据业务需要执行重试、降级或告警。
实用场景
- 保存新闻 SERP 原始 HTML:归档指定在不同地区的新闻搜索页面,用于审计排名变化和复盘历史搜索结果。
- 解析新闻结果版块:提取新闻标题、来源、发布时间和链接,构建级别的新闻监测数据集。
- 对比不同地区的新闻:按位置、语言和搜索引擎域名抓取 SERP,评估品牌或议题在不同市场的新闻可见度。
- 监测竞争对手新闻排名:定期抓取竞争品牌的新闻页面,识别媒体、排名波动和潜在舆变化。
- 验证 SEO 工解析结果:获取未经二次加工的页面 HTML,与自有解析器或 SERP 监测系统进行结果校验。