主题
获取 Amazon 商品 HTML 结果
GET /v3/merchant/amazon/products/task_get/html/{id}
接口说明
通过任务 id 获取已提交 Amazon 商品采集任务的 HTML 结果。
- 请求方式:
GET - 接口路径:
/v3/merchant/amazon/products/task_get/html/$id
完整请求地址示例:
https://api.seermartech.cn/v3/merchant/amazon/products/task_get/html/$id
计费说明
该接口本身不会重复收费,在创建任务时扣费。任务创建后,可在 7 天多次获取结果。
- 实扣费以响应头
X-SeerMarTech-Charge-CNY为准 - 若本次为结果获取,通常
cost为0
请求参数
路径参数
| 字段 | 类型 | 说明 |
|---|---|---|
id | string | 任务唯一标识,UUID 格式。该 id 可在任务创建后的 7 天 用于随时获取结果。 |
响应结构
接口返回 JSON 数据,顶层 tasks 数组,每个任务对象对应一个获取结果。
顶层字段
| 字段 | 类型 | 说明 |
|---|---|---|
version | string | 当前 API 版本。 |
status_code | integer | 局状态码。完整错误码见 /v3/appendix/errors。建议在业务中做好异常和错误处理。 |
status_message | string | 局状态信息。 |
time | string | 请求执行耗时,单位秒。 |
cost | float | 本次请求总成本,单位 USD。通常获取结果时为 0。 |
tasks_count | integer | tasks 数组中的任务数量。 |
tasks_error | integer | 返回错误的任务数量。 |
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 | 与创建任务时提交的参数一致。 |
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。 |
items_count | integer | items 数组中的数量。 |
items | array | HTML 页面及数据。 |
tasks[].result[].items[] 字段
| 字段 | 类型 | 说明 |
|---|---|---|
page | integer | 返回的 HTML 页码序号。 |
date | string | HTML 页面抓取时间,UTC 格式:yyyy-mm-dd hh-mm-ss +00:00。 |
html | string | 页面 HTML。 |
使用说明
通常推荐以下流程:
- 通过创建任务接口创建 Amazon 商品采集任务;
- 通过
/v3/merchant/amazon/products/tasks_ready获取已完成任务列表; - 使用任务
id或返回的 HTML 结果地址,调用本接口拉取 HTML。
请求示例
cURL
bash
id="04170913-0696-0179-0000-707d6a06f64b"
curl --location --request GET "https://api.seermartech.cn/v3/merchant/amazon/products/task_get/html/${id}" \
--header "Authorization: Bearer smt_live_YOUR_KEY" \
--header "Content-Type: application/json"Python
python
import requests
task_id = "04170913-0696-0179-0000-707d6a06f64b"
url = f"https://api.seermartech.cn/v3/merchant/amazon/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 = "02201115-0001-0066-0000-c06c8f23fce5";
axios({
method: "get",
url: `https://api.seermartech.cn/v3/merchant/amazon/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);
});结合 tasks_ready 获取结果
如果你希望批量获取已完成任务,可以调用:
GET /v3/merchant/amazon/products/tasks_ready
再逐个请求:
GET /v3/merchant/amazon/products/task_get/html/$id
Python 批量拉取示例
python
import requests
base_url = "https://api.seermartech.cn"
headers = {
"Authorization": "Bearer smt_live_YOUR_KEY",
"Content-Type": "application/json"
}
# 1. 获取已完成任务列表
ready_resp = requests.get(
f"{base_url}/v3/merchant/amazon/products/tasks_ready",
headers=headers
)
ready_data = ready_resp.json
results = []
if ready_data.get("status_code") == 20000:
for task_group in ready_data.get("tasks", []):
for task_info in task_group.get("result", []):
# 2. 使用 endpoint_html 或 id 获取 HTML 结果
endpoint = task_info.get("endpoint_html")
task_id = task_info.get("id")
if endpoint:
resp = requests.get(f"{base_url}{endpoint}", headers=headers)
elif task_id:
resp = requests.get(
f"{base_url}/v3/merchant/amazon/products/task_get/html/{task_id}",
headers=headers
)
else:
continue
results.append(resp.json)
print(results)TypeScript 批量拉取示例
typescript
import axios from "axios";
const baseURL = "https://api.seermartech.cn";
const headers = {
Authorization: "Bearer smt_live_YOUR_KEY",
"Content-Type": "application/json"
};
async function fetchCompletedAmazonHtmlTasks {
const readyResponse = await axios.get(
`${baseURL}/v3/merchant/amazon/products/tasks_ready`,
{ headers }
);
const readyData = readyResponse.data;
const results: any[] = [];
if (readyData.status_code === 20000 && readyData.tasks) {
for (const taskGroup of readyData.tasks) {
if (!taskGroup.result) continue;
for (const task of taskGroup.result) {
try {
if (task.endpoint_html) {
const result = await axios.get(`${baseURL}${task.endpoint_html}`, { headers });
results.push(result.data);
} else if (task.id) {
const result = await axios.get(
`${baseURL}/v3/merchant/amazon/products/task_get/html/${task.id}`,
{ headers }
);
results.push(result.data);
}
} catch (e) {
console.error("获取结果失败", e);
}
}
}
}
return results;
}
fetchCompletedAmazonHtmlTasks.then(console.log).catch(console.error);响应示例
json
{
"version": "0.1.20200416",
"status_code": 20000,
"status_message": "Ok.",
"time": "0.3408 sec.",
"cost": 0,
"tasks_count": 1,
"tasks_error": 0,
"tasks": [
{
"id": "04170913-0696-0179-0000-707d6a06f64b",
"status_code": 20000,
"status_message": "Ok.",
"time": "0.1234 sec.",
"cost": 0,
"result_count": 1,
"path": [
"v3",
"merchant",
"amazon",
"products",
"task_get",
"html",
"04170913-0696-0179-0000-707d6a06f64b"
],
"data": {
"se_type": "organic",
"api": "merchant",
"function": "products",
"se": "amazon",
"location_name": "United States",
"language_name": "English (United States)",
"keyword": "shoes",
"device": "desktop",
"os": "windows"
},
"result": [
{
"keyword": "shoes",
"type": "organic",
"se_domain": "amazon.com",
"location_code": 2840,
"language_code": "en",
"datetime": "2019-11-15 12:57:46 +00:00",
"items_count": 1,
"items": [
{
"page": 1,
"date": "2019-11-15 12:57:46 +00:00",
"html": "<html>...</html>"
}
]
}
]
}
]
}状态码与错误处理
建议同时检查两层状态:
- 顶层
status_code:判断整个请求是否成功; tasks[].status_code:判断任务是否成功。
常见处理建议
| 场景 | 建议 |
|---|---|
顶层 status_code 非 20000 | 视为接口请求失败,记录 status_message 并重试或告警。 |
tasks[].status_code 为错误码 | 说明该任务处理失败,建议记录任务 id 和错误信息。 |
result 为空 | 任务可能尚未完成、已过期,或无可用结果。 |
| 查询时间 7 天 | 任务结果可能已不可用,建议重新创建任务。 |
错误码请参考:/v3/appendix/errors
字段补说明
data 对象
该对象会原样返回创建任务时提交的主要参数,便于你在结果回收时进行任务映射,例如:
- 归属
- 国家 / 语言维度识别
- 设备类型识别
- 操作系统区分
html 字段用途
html 返回抓取到的原始页面源码,适用于:
- 自定义页面解析
- 调试页面结构变化
- 校验结构化结果与原始页面的一致性
- 保存页面快用于审计或模型训练
实用场景
- 抓取商品搜索结果页源码,用于解析自然商品位、广告位、价格、评分等字段,支撑电商 SEO 与竞品监控。
- 回溯页面结构变化,通过对比不同时期的
html,及时发现平台模板改版对采集和排名分析的影响。 - 校验结构化采集结果,将 HTML 原文与解析后的字段交叉验证,提升商品数据抽取准确率。
- 保存搜索结果页面快,为运营复盘、异常排查、证据留存提供原始页面依据。
- 训练自定义解析模型,基于历史 HTML 样本优化商品标题、品牌、价格、评论等字段的识别能力。