主题
Google News SERP 任务创建
POST /v3/serp/google/news/task_post
本接口用于创建 Google News SERP 抓取任务,返回任务 ID。接口契约为:
POST https://api.seermartech.cn/v3/serp/google/news/task_post
SERP 结果会根据指定的搜索位置和语言生成。平台限流以认证说明中的 30/60/120 次/分钟规则为准。单次请求 100 个任务时,出部分将返回错误码 40006。
任务创建后,可通过返回的任务 ID 获取结果;也可以在请求中 pingback_url 或 postback_url,由本平台在任务完成后主动通知。
> 所有 POST 请求体使用 UTF-8 编码的 JSON 数组格式:[{ ... }]。
计费说明
本接口在成功创建任务时计费。任务深度、执行优级和像素排名等参数可能影响费用。
扣费以响应头 X-SeerMarTech-Charge-CNY 为准。
depth过 10 时,如果返回结果 10 条,可能产生额外费用。- 如果请求的
depth高于返回结果数量,未使用部分将自动退还。 priority=2(高优级)会产生额外费用。calculate_rectangles=true时,单任务费用将乘以 2。- 中特定高级搜索操作符时,单任务费用将乘以 5。
认证方式
请求头使用 Bearer Token:
http
Authorization: Bearer smt_live_YOUR_KEY
Content-Type: application/json请求参数
核心参数
| 参数 | 类型 | 填 | 说明 |
|---|---|---|---|
keyword | string | 是* | 搜索,最长 700 个字符。所有 %XX 编码都会被解码,字符 + 会被解码为空格。若中需要使用 %,请编码为 %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 时填。使用此参数后,无需再传 location_name 或 location_coordinate。示例:2840。 |
language_code | string | 条件填 | 搜索语言代码。未指定 language_name 时填。使用此参数后,无需再传 language_name。示例:en。 |
depth | integer | 否 | SERP 解析深度,即需要获取的结果数量。默认值为 10,最大值为 700。 |
priority | integer | 否 | 任务优级:1 表示普通优级,默认值;2 表示高优级。高优级任务会额外计费。 |
pingback_url | string | 否 | 任务完成后的通知地址。本平台将向该地址发送 GET 请求。URL 中可使用 $id 和 $tag 占位符,发送时会替换为任务 ID 和 URL 编码后的标签值。特殊字符会进行 URL 编码,例如 # 会编码为 %23。 |
postback_url | string | 否 | 任务完成后的结果回调地址。本平台会向该地址发送任务结果的 POST 请求,使用 gzip 压缩。URL 中可使用 $id 和 $tag 占位符。 |
postback_data | string | postback_url 存在时填 | 指定回调数据格式。可选值:advanced、html。 |
* keyword 为常规任务的填参数;如果使用 url 参数,可通过 URL 传递搜索条件。
附加参数
| 参数 | 类型 | 填 | 说明 |
|---|---|---|---|
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 | 否 | 搜索查询的附加参数。 |
calculate_rectangles | boolean | 否 | 是否计算高级结果中 SERP素的像素排名。像素排名表示结果摘要与屏幕左上角之间的距离。默认值为 false;设为 true 时,单任务费用将乘以 2。 |
browser_screen_width | integer | 否 | 浏览器屏幕宽度,用于计算指定设备的像素排名。默认值:1920。在 calculate_rectangles=true 时生效。 |
browser_screen_height | integer | 否 | 浏览器屏幕高度,用于计算指定设备的像素排名。默认值:1080。在 calculate_rectangles=true 时生效。 |
browser_screen_resolution_ratio | integer | 否 | 浏览器屏幕分辨率比例,用于计算像素排名。默认值:1。在 calculate_rectangles=true 时生效。 |
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。 |
位置和语言代码可通过对应的列表接口查询:
- 位置列表:
/v3/serp/wp/locations - 语言列表:
/v3/serp/wp/languages
上述路径为容路径,请以本平台开放的接口权限为准。
请求示例
curl
bash
curl --location --request POST \
"https://api.seermartech.cn/v3/serp/google/news/task_post" \
--header "Authorization: Bearer smt_live_YOUR_KEY" \
--header "Content-Type: application/json" \
--data-raw '[
{
"language_code": "en",
"location_code": 2840,
"keyword": "albert einstein"
},
{
"language_name": "English",
"location_name": "United States",
"keyword": "albert einstein",
"priority": 2,
"tag": "some_string_123",
"pingback_url": "https://your-server.com/pingscript?id=$id&tag=$tag"
},
{
"url": "https://www.google.co.uk/search?q=albert%20einstein&hl=en&gl=GB&uule=w+CAIQIFISCXXeIa8LoNhHEZkq1d1aOpZS",
"postback_data": "html",
"postback_url": "https://your-server.com/postbackscript"
}
]'Python
python
import requests
url = "https://api.seermartech.cn/v3/serp/google/news/task_post"
headers = {
"Authorization": "Bearer smt_live_YOUR_KEY",
"Content-Type": "application/json",
}
post_data = [
{
"language_code": "en",
"location_code": 2840,
"keyword": "albert einstein",
},
{
"language_name": "English",
"location_name": "United States",
"keyword": "albert einstein",
"priority": 2,
"tag": "some_string_123",
"pingback_url": "https://your-server.com/pingscript?id=$id&tag=$tag",
},
{
"url": "https://www.google.co.uk/search?q=albert%20einstein&hl=en&gl=GB&uule=w+CAIQIFISCXXeIa8LoNhHEZkq1d1aOpZS",
"postback_data": "html",
"postback_url": "https://your-server.com/postbackscript",
},
]
response = requests.post(url, headers=headers, json=post_data)
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 postData = [
{
language_code: "en",
location_code: 2840,
keyword: "albert einstein",
},
{
language_name: "English",
location_name: "United States",
keyword: "albert einstein",
priority: 2,
tag: "some_string_123",
pingback_url: "https://your-server.com/pingscript?id=$id&tag=$tag",
},
{
url: "https://www.google.co.uk/search?q=albert%20einstein&hl=en&gl=GB&uule=w+CAIQIFISCXXeIa8LoNhHEZkq1d1aOpZS",
postback_data: "html",
postback_url: "https://your-server.com/postbackscript",
},
];
axios
.post(
"https://api.seermartech.cn/v3/serp/google/news/task_post",
postData,
{
headers: {
Authorization: "Bearer smt_live_YOUR_KEY",
"Content-Type": "application/json",
},
}
)
.then((response) => {
// 处理任务创建结果
console.log(response.data);
})
.catch((error) => {
// 处理请求错误
console.error(error.response?.data || error.message);
});响应说明
接口返回 JSON 对象 tasks 数组每个任务的创建结果。
顶层字段
| 字段 | 类型 | 说明 |
|---|---|---|
version | string | 当前 API 版本。 |
status_code | integer | 请求总体状态码。20000 表示请求成功。 |
status_message | string | 请求总体状态信息。 |
time | string | 请求处理耗时,单位为秒。 |
cost | float | 平台原始 USD 成本兼容字段;人民币实扣以 X-SeerMarTech-Charge-CNY 为准。 |
tasks_count | integer | tasks 数组中的任务数量。 |
tasks_error | integer | tasks 数组中创建失败的任务数量。 |
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 数组中的结果数量。创建任务时通常为 0。 |
path | array | 结果资源路径。 |
data | object | 创建任务时提交的参数及本平台补的标准化参数。 |
result | array | null | 任务结果。创建任务接口返回时为 null。 |
完整错误码请参考错误码文档。
响应示例
json
{
"version": "0.1.20200129",
"status_code": 20000,
"status_message": "Ok.",
"time": "0.0818 sec.",
"cost": 0.0045,
"tasks_count": 3,
"tasks_error": 0,
"tasks": [
{
"id": "01291721-1535-0066-0000-2e7a8bf7302c",
"status_code": 20100,
"status_message": "Task Created.",
"time": "0.0050 sec.",
"cost": 0.0015,
"result_count": 0,
"path": [],
"data": {
"api": "serp",
"function": "task_post",
"se": "google",
"se_type": "news",
"language_code": "en",
"location_code": 2840,
"keyword": "albert einstein",
"device": "desktop",
"os": "windows"
},
"result": null
},
{
"id": "01291721-1535-0066-0000-ed3110168d43",
"status_code": 20100,
"status_message": "Task Created.",
"time": "0.0040 sec.",
"cost": 0.0015,
"result_count": 0,
"path": [],
"data": {
"api": "serp",
"function": "task_post",
"se": "google",
"se_type": "news",
"language_name": "English",
"location_name": "United States",
"keyword": "albert einstein",
"pingback_url": "https://your-server.com/pingscript?id=$id&tag=$tag",
"tag": "some_string_123",
"device": "desktop",
"os": "windows"
},
"result": null
},
{
"id": "01291721-1535-0066-0000-2e7a8bf7302c",
"status_code": 20100,
"status_message": "Task Created.",
"time": "0.0040 sec.",
"cost": 0.0015,
"result_count": 0,
"path": [],
"data": {
"api": "serp",
"function": "task_post",
"se": "google",
"se_type": "news",
"url": "https://www.google.co.uk/search?q=albert%20einstein&hl=en&gl=GB&uule=w+CAIQIFISCXXeIa8LoNhHEZkq1d1aOpZS",
"postback_data": "html",
"postback_url": "https://your-server.com/postbackscript",
"device": "desktop",
"os": "windows"
},
"result": null
}
]
}注意事项
- 每次 POST 请求最多 100 个任务。
- 任务创建成功后,应保存返回的
id,用于后续查询结果。 - 使用
pingback_url时,本平台会发送 GET 请求;使用postback_url时,本平台会发送 gzip 压缩的 POST 请求。 - 如果回调服务器在 10 秒未返回响应,连接将因时中断,任务会转“任务就绪”列表。
- 本接口返回桌面端结果,
os可设置为windows或macos。 location_code、location_name、location_coordinate三应选择一;language_code和language_name也应选择一。calculate_rectangles、browser_screen_width、browser_screen_height和browser_screen_resolution_ratio应合使用。
实用场景
- 监控新闻排名:批量提交品牌、产品或行业,跟踪在 Google News 中的位置和竞争表现,支持舆与 SEO 运营决策。
- 分析竞争对手新闻覆盖:按指定国家、地区和语言抓取新闻 SERP,比较竞争品牌的媒体出现频率和排名优势。
- 评估新闻传播效果:通过
depth获取更深层的新闻结果,判断文章发布后的搜索可见度和长尾。 - 构建区域化新闻 SEO 报告:组合
location_code、language_code和se_domain,生成不同市场的新闻搜索排名报告,化运营。 - 接实时任务通知流程:
pingback_url或postback_url,在任务完成后自动触发数据库、告警和日报生成,减少轮询开销。