Skip to content

通过任务 ID 获取 WordPress V2 SERP HTML 结果

GET /v3/serp/wp/v2/task_get/html/{id}

接口说明

用于根据任务 ID 获取已完成的 WordPress V2 SERP HTML 抓取结果。

  • 请求方式:GET
  • 请求地址:https://api.seermartech.cn/v3/serp/wp/v2/task_get/html/$id

计费说明

该接口本身不会重复收费,费用在创建任务时产生。任务提交后,可在 7 天多次获取结果。

  • 实扣费以响应头 X-SeerMarTech-Charge-CNY 为准
  • 本接口通常返回 cost: 0

路径参数

字段类型说明
idstring任务唯一标识,UUID 格式。任务创建后,可在 7 天随时通过该 ID 获取结果。

响应结构

接口返回 JSON 数据,顶层 tasks 数组,每个任务对象中对应结果。

顶层字段

字段类型说明
versionstring当前 API 版本
status_codeinteger通用状态码。完整错误码见 /v3/appendix/errors
status_messagestring通用状态信息
timestring请求执行时间,单位秒
costfloat本次请求总成本,单位 USD
tasks_countintegertasks 数组中的任务数量
tasks_errorinteger返回错误的任务数量
tasksarray任务结果数组

tasks[] 字段

字段类型说明
idstring任务唯一标识,UUID 格式
status_codeinteger任务状态码,范围通常为 10000-60000,完整定义见 /v3/appendix/errors
status_messagestring任务状态信息
timestring任务执行时间,单位秒
costfloat该任务成本,单位 USD
result_countintegerresult 数组中的结果数量
patharray请求路径
dataobject与创建任务时传参数一致
resultarray结果数组

result[] 字段

字段类型说明
keywordstring创建任务时的。返回时会对 %## 进行解码,+ 会被还原为空格
typestring创建任务时的搜索引擎类型
se_domainstring创建任务时的搜索引擎域名
location_codeinteger创建任务时的地区代码
language_codestring创建任务时的语言代码
datetimestring获取结果的时间,UTC 格式:yyyy-mm-dd hh-mm-ss +00:00
items_countintegeritems 数组中的结果数量
itemsarraySERP 中返回的结果项

items[] 字段

字段类型说明
pageinteger返回的 HTML 页码序号
datestringHTML 页面抓取时间,UTC 格式:yyyy-mm-dd hh-mm-ss +00:00
htmlstringHTML 页面原始

获取方式说明

通常有两种方式获取结果:

  1. 直接通过已知任务 ID 调用: /v3/serp/wp/v2/task_get/html/$id
  2. 调用已完成任务列表接口: /v3/serp/wp/v2/tasks_ready 再逐个读取返回的结果地址或任务 ID

请求示例

cURL

bash
id="02261816-2027-0066-0000-c27d02864073"

curl --location --request GET "https://api.seermartech.cn/v3/serp/wp/v2/task_get/html/${id}" \
--header "Authorization: Bearer smt_live_YOUR_KEY" \
--header "Content-Type: application/json"

Python

python
import requests

task_id = "02231256-2604-0066-2000-57133b8fc54e"
url = f"https://api.seermartech.cn/v3/serp/wp/v2/task_get/html/{task_id}"

headers = {
 "Authorization": "Bearer smt_live_YOUR_KEY",
 "Content-Type": "application/json"
}

response = requests.get(url, headers=headers)
print(response.json)

TypeScript

typescript
import axios from "axios";

const taskId = "02231256-2604-0066-2000-57133b8fc54e";

axios({
 method: "get",
 url: `https://api.seermartech.cn/v3/serp/wp/v2/task_get/html/${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);
 });

获取已完成任务,再批量读取结果

Python

python
import requests

headers = {
 "Authorization": "Bearer smt_live_YOUR_KEY",
 "Content-Type": "application/json"
}

# 1. 获取已完成任务列表
ready_resp = requests.get(
 "https://api.seermartech.cn/v3/serp/wp/v2/tasks_ready",
 headers=headers
)
ready_data = ready_resp.json

results = []

if ready_data.get("status_code") == 20000:
 for task in ready_data.get("tasks", []):
 for task_info in task.get("result", []):
 # 2. 使用 endpoint_html 获取 HTML 结果
 endpoint = task_info.get("endpoint_html")
 if endpoint:
 result_resp = requests.get(
 f"https://api.seermartech.cn{endpoint}",
 headers=headers
 )
 results.append(result_resp.json)

 # 3. 或直接通过任务 ID 获取
 # task_id = task_info.get("id")
 # if task_id:
 # result_resp = requests.get(
 # f"https://api.seermartech.cn/v3/serp/wp/v2/task_get/html/{task_id}",
 # headers=headers
 # )
 # results.append(result_resp.json)

print(results)

TypeScript

typescript
import axios from "axios";

const headers = {
 Authorization: "Bearer smt_live_YOUR_KEY",
 "Content-Type": "application/json"
};

async function fetchCompletedHtmlResults {
 const tasksResponses: any[] = [];

 const readyResponse = await axios.get(
 "https://api.seermartech.cn/v3/serp/wp/v2/tasks_ready",
 { headers }
 );

 const tasksInfo = readyResponse.data;

 if (tasksInfo.status_code === 20000) {
 for (const task of tasksInfo.tasks || []) {
 for (const item of task.result || []) {
 if (item.endpoint_html) {
 const taskGetResponse = await axios.get(
 `https://api.seermartech.cn${item.endpoint_html}`,
 { headers }
 );
 tasksResponses.push(taskGetResponse.data);
 }

 // 也可以直接按任务 ID 拉取
 // if (item.id) {
 // const taskGetResponse = await axios.get(
 // `https://api.seermartech.cn/v3/serp/wp/v2/task_get/html/${item.id}`,
 // { headers }
 // );
 // tasksResponses.push(taskGetResponse.data);
 // }
 }
 }
 } else {
 console.error(`error. Code: ${tasksInfo.status_code} Message: ${tasksInfo.status_message}`);
 }

 console.log(tasksResponses);
}

fetchCompletedHtmlResults.catch(console.error);

响应示例

json
{
 "version": "0.1.20200129",
 "status_code": 20000,
 "status_message": "Ok.",
 "time": "0.3212 sec.",
 "cost": 0,
 "tasks_count": 1,
 "tasks_error": 0,
 "tasks": [
 {
 "data": {
 "api": "serp",
 "function": "task_get",
 "se": "wp",
 "se_type": "v2",
 "location_code": 2156,
 "keyword": "flight ticket new york san francisco",
 "tag": "tag1",
 "device": "desktop",
 "os": "windows"
 },
 "result": [
 {
 }
 ]
 }
 ]
}

错误处理建议

建议在集成时同时处理以下层级的状态信息:

  1. 顶层 status_code:判断整个请求是否成功
  2. tasks[].status_code:判断单个任务是否成功
  3. result 是否为空:成功状态下也可能因任务未完成、结果过期或无可用数据而无

可重点:

  • 20000:请求成功
  • 40000 及以上:通常表示任务级错误或请求异常
  • 详细错误码与说明参考:/v3/appendix/errors

注意事项

  • 任务结果保证在 7 天可获取
  • html 字段返回的是原始页面源码,体积可能较大
  • keyword 字段会经过 URL 解码处理,+ 号会被转换为空格
  • 如果需要批量获取结果,建议调用 /v3/serp/wp/v2/tasks_ready
  • 本接口为结果读取接口,不用于创建任务

实用场景

  • 抓取原始 SERP HTML,用于还原搜索结果页结构,支持排名波动、模块分布和页面分析
  • 复核解析结果,在结构化字段之外保留原始页面源码,便于排查解析异常或页面改版影响
  • 留存搜索页面快,为竞品监控、SERP 变化对比和问题回溯提供证据链
  • 分析搜索特征模块,基于 HTML 识别自然结果、富媒体区块、等页面分布
  • 建立页面样本库,为 SEO 策略研究、模板识别和自动化页面分类提供底层数据支持

统一入口:官网 · LLM API · 控制台