主题
获取 Google Shopping 商品 HTML 结果
GET /v3/merchant/google/products/task_get/html/${id}
通过任务 id 获取已提交的 Google Shopping 商品采集任务的 HTML 页面结果。
接口说明
请求方式: GET请求路径: /v3/merchant/google/products/task_get/html/$id
该接口用于按任务 ID 获取结果。任务提交成功后,可在 7 天多次获取该任务结果;在创建任务时计费。扣费以响应头 X-SeerMarTech-Charge-CNY 为准。
请求参数
路径参数
| 字段 | 类型 | 说明 |
|---|---|---|
id | string | 任务唯一标识,UUID 格式。该 ID 可在任务创建后的 7 天 用于随时获取结果。 |
响应结构
接口返回 JSON 数据,顶层 tasks 数组。
顶层字段
| 字段 | 类型 | 说明 |
|---|---|---|
version | string | 当前 API 版本。 |
status_code | integer | 通用状态码。完整错误码请参考 /v3/appendix/errors。建议在接时做好异常处理。 |
status_message | string | 通用状态信息。完整说明请参考 /v3/appendix/errors。 |
time | string | 接口执行耗时,单位秒。 |
cost | float | 本次请求总成本,单位 USD。获取结果通常不额外计费,以返回值为准。 |
tasks_count | integer | tasks 数组中的任务数。 |
tasks_error | integer | tasks 数组中返回错误的任务数。 |
tasks | array | 任务结果数组。 |
tasks[] 字段
| 字段 | 类型 | 说明 |
|---|---|---|
id | string | 任务唯一标识,UUID 格式。 |
status_code | integer | 任务状态码,范围通常为 10000-60000。完整错误码请参考 /v3/appendix/errors。 |
status_message | string | 任务状态说明。 |
time | string | 任务执行耗时,单位秒。 |
cost | float | 该任务成本,单位 USD。 |
result_count | integer | result 数组中的数量。 |
path | array | 请求路径。 |
data | object | 与创建任务时 POST 请求中传的参数一致。 |
result | array | 结果数组。 |
tasks[].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。例如:2019-11-15 12:57:46 +00:00 |
items_count | integer | items 数组中的结果数量。 |
items | array | Google Shopping 搜索结果项。 |
tasks[].result[].items[] 字段
| 字段 | 类型 | 说明 |
|---|---|---|
page | integer | 返回的 HTML 页序号。 |
date | string | HTML 页面抓取时间,UTC 格式:yyyy-mm-dd hh-mm-ss +00:00。例如:2019-11-15 12:57:46 +00:00 |
html | string | 抓取到的原始 HTML。 |
调用说明
通常推荐的处理流程如下:
- 通过任务提交接口创建采集任务;
- 再通过
/v3/merchant/google/products/tasks_ready获取已完成任务列表; - 使用返回的任务 ID 或结果端点地址,调用本接口拉取 HTML 结果。
请求示例
cURL
bash
id="04171054-0696-0179-0000-e56ea58342c5"
curl --location --request GET "https://api.seermartech.cn/v3/merchant/google/products/task_get/html/${id}" \
--header "Authorization: Bearer smt_live_YOUR_KEY" \
--header "Content-Type: application/json"Python
python
import requests
task_id = "02231453-2604-0066-2000-64d39c6677d4"
url = f"https://api.seermartech.cn/v3/merchant/google/products/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 = "02231453-2604-0066-2000-64d39c6677d4";
axios({
method: "get",
url: `https://api.seermartech.cn/v3/merchant/google/products/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);
});获取已完成任务后获取结果
如果你希望批量处理已完成任务,可以请求:
GET /v3/merchant/google/products/tasks_ready
然后对返回结果中的 HTML 结果端点逐个发起请求,或根据任务 ID 拼接本接口地址获取数据。
Python 示例:取已完成任务,再拉取 HTML 结果
python
import requests
headers = {
"Authorization": "Bearer smt_live_YOUR_KEY",
"Content-Type": "application/json"
}
# 1. 获取已完成任务列表
ready_url = "https://api.seermartech.cn/v3/merchant/google/products/tasks_ready"
ready_resp = requests.get(ready_url, headers=headers).json
results = []
if ready_resp.get("status_code") == 20000:
for task in ready_resp.get("tasks", []):
for item in task.get("result", []) if task.get("result") else []:
endpoint = item.get("endpoint_html")
if endpoint:
# 2. 获取每个已完成任务的 HTML 结果
resp = requests.get(f"https://api.seermartech.cn{endpoint}", headers=headers)
results.append(resp.json)
print(results)响应示例
json
{
"version": "0.1.20200416",
"status_code": 20000,
"status_message": "Ok.",
"time": "0.1847 sec.",
"cost": 0,
"tasks_count": 1,
"tasks_error": 0,
"tasks": [
{
"data": {
"se_type": "shopping",
"api": "merchant",
"function": "products",
"se": "google",
"language_code": "en",
"location_code": 2840,
"keyword": "iphone",
"price_min": "5",
"priority": 2,
"device": "desktop",
"os": "windows"
},
"result": [
{
}
]
}
]
}状态码与异常处理
- 顶层
status_code表示整个请求是否成功; tasks[].status_code表示任务是否成功;- 建议同时校验:
- 顶层
status_code == 20000 tasks_error == 0tasks[].result非空
完整错误码和信息说明请参考 /v3/appendix/errors。
注意事项
- 本接口返回的是 原始 HTML 页面,适合需要自行解析页面结构的场景。
- 任务结果保证在任务创建后的 7 天 可获取。
- 获取结果通常不会重复计费,以返回中的
cost字段为准。 keyword字段会进行 URL 解码,+会显示为空格。
实用场景
- 抓取商品结果页源码:获取 Google Shopping 原始 HTML,用于自建解析器提取标题、价格、商家等字段。
- 校验采集结果完整性:对比 HTML 页面与结构化结果,排查字段缺失、解析异常或页面改版影响。
- 复盘竞品商品展示:保存指定下的商品结果页快,用于分析竞品位置、价格策略和页面样式变化。
- 训练页面解析规则:基于真实 HTML 样本开发或迭代 XPath、CSS Selector、正则规则,提高商品数据抽取准确率。
- 构建页面存档能力:按、地区、语言定期保存 Shopping 页面原文,为 SEO/电商报分析提供可追溯底稿。