主题
按任务 ID 获取好搜自然搜索结果(高级版)
接口说明
GET https://api.seermartech.cn/v3/serp/haosou/organic/task_get/advanced/$id
本接口根据任务 ID 获取好搜(Haosou)自然搜索结果的高级数据。任务提交成功后,可在 30 天重复获取任务结果;系统对任务提交操作计费。
扣费以响应头 X-SeerMarTech-Charge-CNY 为准。
请求参数
请求无需请求体,任务 ID 通过 URL 路径传递。
| 参数 | 类型 | 说明 |
|---|---|---|
id | string | 任务唯一标识,UUID 格式。任务提交后 30 天可使用该 ID 获取结果。 |
请求示例
cURL
bash
id="02261816-2027-0066-0000-c27d02864073"
curl --location --request GET \
"https://api.seermartech.cn/v3/serp/haosou/organic/task_get/advanced/${id}" \
--header "Authorization: Bearer smt_live_YOUR_KEY" \
--header "Content-Type: application/json"Python
python
import requests
task_id = "02231256-2604-0066-2000-57133b8fc54e"
response = requests.get(
f"https://api.seermartech.cn/v3/serp/haosou/organic/task_get/advanced/{task_id}",
headers={
"Authorization": "Bearer smt_live_YOUR_KEY",
"Content-Type": "application/json",
},
)
data = response.json()
print(data)TypeScript
typescript
import axios from "axios";
const taskId = "02231256-2604-0066-2000-57133b8fc54e";
axios
.get(
`https://api.seermartech.cn/v3/serp/haosou/organic/task_get/advanced/${taskId}`,
{
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 | 请求级状态码。 |
status_message | string | 请求级状态说明。 |
time | string | 接口执行耗时,例如 0.0819 sec.。 |
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 | array/object | 创建任务时提交的参数。 |
result | array | SERP 结果数组。 |
result 字段
| 字段 | 类型 | 说明 |
|---|---|---|
keyword | string | 请求中的。返回值会对 URL 编码进行解码,+ 会被解码为空格。 |
type | string | 请求中的搜索类型,例如 organic。 |
se_domain | string | 搜索引擎域名。 |
location_code | integer | 地区代码。好搜会忽略地区设置,因此该值固定为 0。 |
language_code | string | 请求中的语言代码。 |
check_url | string | 直接访问搜索结果页的 URL,可用于人工核验结果准确性。 |
datetime | string | 获取结果的日期和时间,格式为 YYYY-MM-DD HH:mm:ss ±UTC偏移,例如 2019-11-15 12:57:46 +00:00。 |
spell | array | 搜索引擎自动纠错信息。 |
item_types | array | 当前 SERP 中出现的结果类型。可能 local_pack、map、organic、paid、related_searches、video、images。 |
se_results_count | integer | SERP 中的结果总数。 |
items_count | integer | items 数组中的结果数量。 |
items | array | SERP 结果数组。 |
spell 自动纠错字段
| 字段 | 类型 | 说明 |
|---|---|---|
keyword | string | 搜索引擎自动纠正后的,结果该返回。 |
type | string | 纠错类型。可选值:did_you_mean、showing_results_for、no_results_found_for。 |
SERP 通用字段
以下字段适用于多种 SERP素:
| 字段 | 类型 | 说明 |
|---|---|---|
type | string | SERP素类型。 |
rank_group | integer | 同类型中的分组排名。不同类型之间不计该排名。 |
rank_absolute | integer | 在 SERP素中的绝对排名。 |
position | string | 素在页面中的对齐位置,可为 left 或 right。 |
xpath | string | SERP素对应的 XPath。 |
rectangle | array/null | 素在 SERP 中的坐标和尺寸。当提交任务时未将 calculate_rectangles 设置为 true 时为 null。 |
rectangle 字段
| 字段 | 类型 | 说明 |
|---|---|---|
x | integer | 素左上角的横坐标。 |
y | integer | 素左上角的纵坐标。 |
width | integer | 素宽度,单位为像素。 |
height | integer | 素高度,单位为像素。 |
坐标原点为 SERP 页面左上角。
自然结果 organic
当 type 为 organic 时,结果对象还以下字段:
| 字段 | 类型 | 说明 |
|---|---|---|
domain | string | 搜索结果域名。 |
title | string | 搜索结果标题。 |
url | string | 搜索结果 URL。 |
cache_url | string/null | 页面缓存 URL。 |
breadcrumb | string | 搜索结果面屑路径。 |
is_image | boolean | 是否图片。 |
is_video | boolean | 是否视频。 |
is_featured_snippet | boolean | 是否为精选摘要。 |
is_malicious | boolean | 是否被标记为恶意结果。 |
is_web_story | boolean | 是否为 Web Story。 |
description | string | SERP 中展示的结果描述。 |
pre_snippet | string/null | 展示在结果描述前的附加信息。 |
extended_snippet | string/null | 展示在结果描述后的附加信息。 |
amp_version | boolean | 是否存在 AMP(加速移动页面)版本。 |
rating | array/null | 结果评分信息。 |
highlighted | array/null | 结果描述中以粗体突出显示的词语。 |
links | array/null | 站点链接。无站点链接时为 null。 |
faq | array/null | FAQ 问答扩展。无 FAQ 时为 null。 |
timestamp | string/null | 结果发布时间,格式为 YYYY-MM-DD HH:mm:ss ±UTC偏移。 |
rectangle | array/null | 结果的页面坐标和尺寸。 |
rating 评分字段
| 字段 | 类型 | 说明 |
|---|---|---|
rating_type | string | 评分类型,可为 Max5、Percents 或 CustomMax。 |
value | integer | 评分值。 |
votes_count | integer | 评价数量。 |
rating_max | integer | 当前评分类型的最大值。 |
links 站点链接字段
| 字段 | 类型 | 说明 |
|---|---|---|
type | string | 固定为 link_element。 |
title | string | 链接标题。 |
description | string | 链接描述。 |
url | string | 站点链接 URL。 |
faq FAQ 字段
faq 通常一个或多个 FAQ 容器:
| 字段 | 类型 | 说明 |
|---|---|---|
type | string | 固定为 faq_box。 |
items | array | FAQ 条目数组。 |
FAQ 条目字段:
| 字段 | 类型 | 说明 |
|---|---|---|
type | string | 固定为 faq_box_element。 |
title | string | 问题标题。 |
description | string | 下拉区域中的答案。 |
links | array/null | FAQ 条目中的链接。 |
FAQ 链接字段:
| 字段 | 类型 | 说明 |
|---|---|---|
type | string | 固定为 link_element。 |
title | string | 链接锚文本。 |
url | string | 链接 URL。 |
付费结果 paid
当 type 为 paid 时,结果对象以下字段:
| 字段 | 类型 | 说明 |
|---|---|---|
domain | string | 广告结果域名。 |
description | string | 广告描述。 |
title | string | 广告标题。 |
url | string | 广告目标 URL。 |
breadcrumb | string/null | 广告结果面屑路径。 |
highlighted | array/null | 描述中突出显示的词语。 |
extra | array/object/null | 广告附加信息。 |
description_rows | array/null | 扩展描述信息。 |
links | array/null | 广告站点链接。 |
ad_aclk | string/null | 广告标识。 |
rectangle | array/null | 广告的页面坐标和尺寸。 |
付费结果中的 links 使用以下字段:
| 字段 | 类型 | 说明 |
|---|---|---|
type | string | 固定为 link_element。 |
title | string | 链接标题。 |
description | string | 链接描述。 |
url | string | 链接 URL。 |
ad_aclk | string/null | 链接对应的广告标识。 |
搜索 related_searches
| 字段 | 类型 | 说明 |
|---|---|---|
type | string | 固定为 related_searches。 |
rank_group | integer | 同类型中的分组排名。 |
rank_absolute | integer | 在 SERP素中的绝对排名。 |
position | string | 对齐位置,可为 left 或 right。 |
xpath | string | 素 XPath。 |
items | array/null | 搜索条目。 |
rectangle | array/null | 素坐标和尺寸。 |
本地结果 local_pack
| 字段 | 类型 | 说明 |
|---|---|---|
type | string | 固定为 local_pack。 |
title | string | 本地商户或地点名称。 |
description | string | 本地结果描述。 |
domain | string/null | 商户域名。 |
phone | string/null | 电话号码。 |
url | string/null | URL。 |
is_paid | boolean | 是否为广告结果。 |
rating | array/null | 商户评分,字段结构同 rating。 |
cid | string/null | 本地商户唯一客户端 ID。 |
rectangle | array/null | 素坐标和尺寸。 |
地图结果 map
| 字段 | 类型 | 说明 |
|---|---|---|
type | string | 固定为 map。 |
rank_group | integer | 同类型中的分组排名。 |
rank_absolute | integer | 在 SERP素中的绝对排名。 |
position | string | 对齐位置,可为 left 或 right。 |
xpath | string | 素 XPath。 |
title | string | 地图结果标题。 |
url | string | 地图结果 URL。 |
rectangle | array/null | 素坐标和尺寸。 |
视频结果 video
| 字段 | 类型 | 说明 |
|---|---|---|
type | string | 固定为 video。 |
rank_group | integer | 同类型中的分组排名。 |
rank_absolute | integer | 在 SERP素中的绝对排名。 |
position | string | 对齐位置,可为 left 或 right。 |
xpath | string | 素 XPath。 |
items | array/null | 视频条目数组。 |
rectangle | array/null | 素坐标和尺寸。 |
视频条目字段:
| 字段 | 类型 | 说明 |
|---|---|---|
type | string | 固定为 video_element。 |
source | string | 视频来源。 |
title | string | 视频标题。 |
timestamp | string/null | 视频发布时间。 |
url | string | 视频 URL。 |
rectangle | array/null | 视频条目的坐标和尺寸。 |
图片结果 images
| 字段 | 类型 | 说明 |
|---|---|---|
type | string | 固定为 images。 |
rank_group | integer | 同类型中的分组排名。 |
rank_absolute | integer | 在 SERP素中的绝对排名。 |
position | string | 对齐位置,可为 left 或 right。 |
xpath | string | 素 XPath。 |
title | string | 图片结果标题。 |
url | string | 图片结果页面 URL。 |
items | array/null | 图片条目数组。 |
rectangle | array/null | 素坐标和尺寸。 |
图片条目字段:
| 字段 | 类型 | 说明 |
|---|---|---|
type | string | 固定为 images_element。 |
alt | string | 图片替代文本。 |
url | string | 图片 URL。该 URL 可能指向原始资源,也可能指向本平台存储的图片资源。 |
rectangle | array/null | 图片条目的坐标和尺寸。 |
响应示例
json
{
"version": "0.1.20210105",
"status_code": 20000,
"status_message": "Ok.",
"time": "0.0819 sec.",
"cost": 0,
"tasks_count": 1,
"tasks_error": 0,
"tasks": [
{
"id": "02261816-2027-0066-0000-c27d02864073",
"status_code": 20000,
"status_message": "Ok.",
"time": "0.0700 sec.",
"cost": 0,
"result_count": 1,
"path": [
"v3",
"serp",
"haosou",
"organic",
"task_get",
"advanced"
],
"data": {
"api": "serp",
"function": "task_get",
"se": "haosou",
"se_type": "organic",
"keyword": "marketing",
"language_code": "zh_CN",
"priority": 2,
"device": "desktop",
"os": "windows"
},
"result": [
{
"keyword": "marketing",
"type": "organic",
"se_domain": "so.com",
"location_code": 0,
"language_code": "zh_CN",
"check_url": "https://www.so.com/s?q=marketing",
"datetime": "2019-11-15 12:57:46 +00:00",
"spell": null,
"item_types": [
"organic",
"paid",
"images",
"video",
"map",
"related_searches",
"local_pack"
],
"se_results_count": 1240000,
"items_count": 10,
"items": [
{
"type": "organic",
"rank_group": 1,
"rank_absolute": 1,
"position": "left",
"xpath": "/html/body/div/div/div/ul/li",
"domain": "www.example.com",
"title": "示例搜索结果",
"url": "https://www.example.com/page",
"cache_url": null,
"breadcrumb": "www.example.com/page",
"is_image": false,
"is_video": false,
"is_featured_snippet": false,
"is_malicious": false,
"is_web_story": false,
"description": "搜索结果描述。",
"pre_snippet": null,
"extended_snippet": null,
"amp_version": false,
"rating": null,
"highlighted": [],
"links": null,
"faq": null,
"timestamp": null,
"rectangle": null
},
{
"type": "paid",
"rank_group": 1,
"rank_absolute": 2,
"position": "left",
"xpath": "/html/body/div/div/div/ul/li/div",
"domain": "ads.example.com",
"description": "广告描述。",
"title": "广告标题",
"url": "https://ads.example.com/landing",
"breadcrumb": null,
"highlighted": null,
"extra": {
"ad_aclk": null
},
"description_rows": null,
"links": null,
"ad_aclk": null,
"rectangle": null
},
{
"type": "images",
"rank_group": 1,
"rank_absolute": 3,
"position": "left",
"xpath": "/html/body/div/div/div/ul/li",
"title": "图片搜索结果",
"url": "https://image.example.com/search?q=marketing",
"items": [],
"rectangle": null
},
{
"type": "video",
"rank_group": 1,
"rank_absolute": 4,
"position": "left",
"xpath": "/html/body/div/div/div/ul/li/div",
"items": [],
"rectangle": null
},
{
"type": "map",
"rank_group": 1,
"rank_absolute": 5,
"position": "left",
"xpath": "/html/body/div/div/div/ul/li/div",
"title": "地图结果",
"url": "https://map.example.com/",
"rectangle": null
},
{
"type": "related_searches",
"rank_group": 1,
"rank_absolute": 6,
"position": "left",
"xpath": "/html/body/div/div/div/div/dl",
"items": [],
"rectangle": null
},
{
"type": "local_pack",
"rank_group": 1,
"rank_absolute": 7,
"position": "left",
"xpath": "/html/body/div/div/div/ul/li/div",
"title": "示例本地商户",
"description": "商户地址及简介。",
"domain": null,
"phone": null,
"url": null,
"is_paid": false,
"rating": null,
"cid": null,
"rectangle": null
}
]
}
]
}
]
}状态码与异常处理
建议根据以下字段实现异常处理:
- 首检查顶层
status_code。 - 再检查每个任务对象中的
status_code。 - 当任务状态码表示失败,或
result为null时,应读取status_message并记录错误。 tasks_error可用于统计本次响应中失败的任务数量。- 业务系统应对任务不存在、任务尚未完成、任务已过期及参数错误等进行重试或告警处理。
实用场景
- 监测自然排名:获取好搜 SERP 中的自然结果、绝对排名和分组排名,评估网站在目标上的可见度变化。
- 分析 SERP 特征占位:识别自然结果、付费广告、图片、视频、地图、本地结果和搜索等,指导与页面结构优化。
- 核验搜索结果准确性:结合
check_url、datetime和xpath对搜索页面进行抽样复核,提升排名监控数据的可信度。 - 评估竞争对手搜索表现:提取竞争页面的域名、标题、URL、描述和面屑信息,建立竞争结果库。
- 优化本地 SEO 与广告策略:分析
local_pack、map和paid结果中的商户、广告及排名信息,本地门店和搜索广告投放决策。