主题
提交 WP V2 SERP 任务
本接口用于创建 SERP 抓取任务,返回指定在指定地区与语言设置下的搜索结果页数据任务。任务创建后,可通过任务 id 轮询获取结果,也可以通过 pingback_url 或 postback_url 在任务完成后接收回调。
接口支持两种执行优级:
1:普通优级(默认)2:高优级
接口说明
- 请求方法:
POST - 请求地址:
https://api.seermartech.cn/v3/serp/wp/v2/task_post
计费与频率限制
- 在创建任务时扣费。
- 参考价请结合响应中的
cost字段评估,扣费以响应中的 cost 字段为准。 depth过10时,如果搜索引擎返回 10 条结果,可能产生额外费用。- 高优级任务
priority=2会产生额外费用。 - 启用
calculate_rectangles=true时,参考价约 ¥0.0096 / 次。 stop_crawl_on_match会按抓取到满足条件前的 SERP 页数计费。- 每分钟最多可发送
2000次 API 调用。 - 每次 POST 最多
100个任务;出后,限任务会返回40006错误。
请求格式
所有 POST 数据需使用 UTF-8 编码的 JSON,并且请求体是 JSON 数组:
json
[
{
"language_code": "en",
"location_code": 2840,
"keyword": "albert einstein"
}
]任务结果获取方式
任务创建成功后,可通过以下方式获取结果:
- 使用返回的唯一任务标识
id主动查询; - 创建任务时设置
pingback_url,任务完成后本平台向该地址发送 GET 通知; - 创建任务时设置
postback_url,任务完成后本平台向该地址发送带 gzip 压缩结果的 POST 请求。
回调说明
- 如果回调服务器在
10秒未响应,请求会时中止; -时后,任务会可查询的就绪任务列表; pingback_url/postback_url中可使用:$id:任务 ID$tag:URL 编码后的自定义标签- 回调 URL 中的特殊字符会被 URL 编码,例如
#会编码为%23
主要参数
| 字段名 | 类型 | 说明 |
|---|---|---|
keyword | string | 填。,最长 700 个字符。所有 %## 会被解码,字符 + 会被解码为空格。如果中需要保留 %,请写为 %25;如需保留 +,请写为 %2B。 |
location_code | integer | 当未指定 location_name 或 location_coordinate 时填。搜索地区代码。若已传该字段,则无需再传 location_name 或 location_coordinate。可通过 /v3/serp/wp/locations 获取可用地区。示例:2840 |
language_code | string | 当未指定 language_name 时填。搜索语言代码。若已传该字段,则无需再传 language_name。可通过 /v3/serp/wp/languages 获取可用语言。示例:en |
depth | integer | 可选。解析深度,即返回的 SERP 结果数量。默认值:10;最大值:700。每 10 条结果通常按一个计费单位计算, 10 可能产生额外费用。 |
priority | integer | 可选。任务优级。1 为普通优级(默认),2 为高优级。高优级会额外扣费。 |
device | string | 可选。设备类型,可选值:desktop、mobile。默认值:desktop |
pingback_url | string | 可选。任务完成后的通知地址,本平台会向该地址发送 GET 请求。可使用 $id 和 $tag 占位。示例:http://your-server.com/pingscript?id=$id |
postback_url | string | 可选。任务完成后的结果回调地址,本平台会向该地址发送 gzip 压缩后的 POST 结果。可使用 $id 和 $tag 占位。 |
postback_data | string | 当指定 postback_url 时填。定义回调结果的数据类型。可选值:regular、advanced、html |
附加参数
| 字段名 | 类型 | 说明 |
|---|---|---|
location_name | string | 当未指定 location_code 或 location_coordinate 时填。搜索地区完整名称。若已传该字段,则无需再传 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 个目标对象。启用后,响应只会返回到匹目标为止的结果。 |
match_type | string | 当指定 stop_crawl_on_match 时填。匹方式,可选值:domain、with_subdomains、wildcard |
match_value | string | 当指定 stop_crawl_on_match 时填。目标域名、子域名或通表达式。不要协议头。示例:"match_value": "example.com"、"match_value": "/blog/post-*" |
max_crawl_pages | integer | 可选。最多抓取的搜索结果页数。默认值:1;最大值:100。该参数与 depth 决定抓取范围。 |
search_param | string | 可选。附加搜索参数,用于控制搜索请求行为。 |
calculate_rectangles | boolean | 可选。是否计算高级结果中的像素排名。像素排名表示结果片段距离屏幕左上角的距离。默认值:false。启用后会额外扣费。 |
browser_screen_width | integer | 可选。用于像素排名计算的浏览器宽度,范围:240-9999。默认值:桌面端 1920,Android 移动端 360,iOS 移动端 375。使用前需设置 calculate_rectangles=true |
browser_screen_height | integer | 可选。用于像素排名计算的浏览器高度,范围:240-9999。默认值:桌面端 1080,Android 移动端 640,iOS 移动端 812。使用前需设置 calculate_rectangles=true |
browser_screen_resolution_ratio | integer | 可选。用于像素排名计算的屏幕分辨率比例,范围:0.5-3。默认值:桌面端 1,Android 移动端 3,iOS 移动端 3。使用前需设置 calculate_rectangles=true |
url | string | 可选。直接传搜索 URL,本接口会自动拆解所需参数。该方式对 URL 中语言与地区要求严格,处理难度更高,通常不推荐。示例:https://www.bing.com/search?q=rank%20checker&count=50&first=1&setlang=en&cc=US&safesearch=Moderate&FORM=SEPAGE |
location_coordinate | string | 当未指定 location_name 或 location_code 时填。GPS 坐标,格式为 "latitude,longitude",经纬度最多 7 位小数。示例:53.476225,-2.243572 |
返回结果说明
接口返回 JSON 数据 tasks 数组,用于描述本次提交的任务状态。
顶层字段
| 字段名 | 类型 | 说明 |
|---|---|---|
version | string | 当前 API 版本 |
status_code | integer | 通用状态码,完整错误码可参考 /v3/appendix/errors |
status_message | string | 通用状态信息 |
time | string | 执行耗时,单位秒 |
cost | float | 本次请求总费用,单位 USD |
tasks_count | integer | tasks 数组中的任务数量 |
tasks_error | integer | tasks 数组中返回错误的任务数量 |
tasks | array | 任务数组 |
tasks 数组字段
| 字段名 | 类型 | 说明 |
|---|---|---|
id | string | 本平台中的唯一任务 ID,UUID 格式 |
status_code | integer | 任务状态码,范围通常为 10000-60000 |
status_message | string | 任务状态信息 |
time | string | 任务处理耗时,单位秒 |
cost | float | 单个任务费用,单位 USD |
result_count | integer | result 数组中的数量 |
path | array | URL 路径 |
data | object | 回显提交时的任务参数 |
result | array | 结果数组;在任务创建接口中该值通常为 null |
请求示例
cURL
bash
curl --location --request POST "https://api.seermartech.cn/v3/serp/wp/v2/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.bing.com/search?q=rank%20checker&count=50&first=1&setlang=en&cc=US&safesearch=Moderate&FORM=SEPAGE",
"postback_data": "html",
"postback_url": "https://your-server.com/postbackscript"
}
]'Python
python
import requests
url = "https://api.seermartech.cn/v3/serp/wp/v2/task_post"
headers = {
"Authorization": "Bearer smt_live_YOUR_KEY",
"Content-Type": "application/json"
}
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.bing.com/search?q=rank%20checker&count=50&first=1&setlang=en&cc=US&safesearch=Moderate&FORM=SEPAGE",
"postback_data": "html",
"postback_url": "https://your-server.com/postbackscript"
}
]
response = requests.post(url, headers=headers, json=data)
print(response.json)TypeScript
typescript
import axios from "axios";
const postArray = [
{
language_name: "English",
location_name: "United States",
keyword: encodeURI("albert einstein")
}
];
axios({
method: "post",
url: "https://api.seermartech.cn/v3/serp/bing/organic/task_post",
headers: {
Authorization: "Bearer smt_live_YOUR_KEY",
"Content-Type": "application/json"
},
data: postArray
})
.then((response) => {
// 返回任务创建结果
console.log(response.data);
})
.catch((error) => {
console.log(error);
});说明:原示例中存在不同容路径写法;如需保持与现有项目一致,请按接的
/v3/...路径调用。
响应示例
json
{
"version": "0.1.20200129",
"status_code": 20000,
"status_message": "Ok.",
"time": "0.2539 sec.",
"cost": 0.0045,
"tasks_count": 3,
"tasks_error": 0,
"tasks": [
{
"id": "11141653-0696-0066-0000-fa25e0da658d",
"status_code": 20100,
"status_message": "Task Created.",
"time": "0.0040 sec.",
"cost": 0.0015,
"result_count": 0,
"path": [
"v3",
"serp",
"wp",
"v2",
"task_post"
],
"data": {
"api": "serp",
"function": "task_post",
"se": "wp",
"se_type": "v2",
"language_code": "en",
"location_code": 2840,
"keyword": "albert einstein",
"device": "desktop",
"os": "windows"
},
"result": null
},
{
"id": "11141653-0696-0066-0000-fa25e0da658e",
"status_code": 20100,
"status_message": "Task Created.",
"time": "0.0055 sec.",
"cost": 0.0015,
"result_count": 0,
"path": [
"v3",
"serp",
"wp",
"v2",
"task_post"
],
"data": {
"api": "serp",
"function": "task_post",
"se": "wp",
"se_type": "v2",
"language_name": "English",
"location_name": "United States",
"keyword": "albert enstein",
"priority": "2",
"pingback_url": "https://your-server.com/pingscript?id=$id&tag=$tag",
"tag": "some_string_123",
"device": "desktop",
"os": "windows"
},
"result": null
},
{
"id": "01291939-1535-0066-0000-170c2bafbc0f",
"status_code": 20100,
"status_message": "Task Created.",
"time": "0.0038 sec.",
"cost": 0.0015,
"result_count": 0,
"path": [
"v3",
"serp",
"wp",
"v2",
"task_post"
],
"data": {
"api": "serp",
"function": "task_post",
"se": "wp",
"se_type": "v2",
"url": "https://www.bing.com/search?q=rank%20checker&count=50&first=1&setlang=en&cc=US&safesearch=Moderate&FORM=SEPAGE",
"postback_data": "html",
"postback_url": "https://your-server.com/postbackscript",
"device": "desktop",
"os": "windows"
},
"result": null
}
]
}常见状态码
| 状态码 | 含义 |
|---|---|
20000 | 请求成功 |
20100 | 任务已创建 |
40006 | 单次 POST 中任务数量上限(100) |
建议在接时建立完整的异常处理机制,并结合
/v3/appendix/errors处理通用错误与业务错误。
使用建议
- 常规场景优使用
keyword + location + language的方式建任务,稳定性更高; - 只有在确实需要复现搜索 URL 时,再使用
url参数; - 当需要监控目标站点排名是否出现时,可结合
stop_crawl_on_match降低无效翻页成本; - 如果需要做像素级可见性分析,再开启
calculate_rectangles及屏幕参数; - 批量提交时建议每次控制在
100个任务,并做好回调重试与结果补拉机制。
实用场景
- 批量采集排名:按国家、语言、设备创建任务,持续获取目标在 SERP 中的表现,用于日常 SEO 排名监控。
- 监控目标域名是否前几页:结合
stop_crawl_on_match,在命中特定域名后停止抓取,降低监控竞品或自有站点排名的抓取成本。 - 构建多地区搜索可见性看板:使用
location_code或location_coordinate提交不同地域任务,分析同一在不同市场的差异。 - 评估移动端与桌面端结果差异:通过
device与os维度对比 SERP,识别不同终端上的排名变化与页面布局差异。 - 分析 SERP 像素位置:启用
calculate_rectangles后获取像素排名,用于评估自然结果在首屏中的可见性与点击潜力。