主题
按任务 ID 获取亚马逊商品 HTML 结果
GET /v3/merchant/amazon/products/tasks_ready
本接口使用 GET 方法,通过任务 ID 获取亚马逊商品抓取任务的 HTML 结果。
请求方式与路径:
http
GET https://api.seermartech.cn/v3/merchant/amazon/products/task_get/html/$id,$id 为创建任务时返回的任务唯一标识。
计费说明
- 创建任务时计费。
- 任务完成后,可在 7 天获取任务结果。
- 实扣费以响应头
X-SeerMarTech-Charge-CNY为准。 - 本接口本身不重复收取结果查询费用。
请求参数
路径参数
| 参数名 | 类型 | 填 | 说明 |
|---|---|---|---|
id | string | 是 | 任务唯一标识,UUID 格式。任务创建后可在 7 天使用该 ID 随时查询结果。 |
请求头
http
Authorization: Bearer smt_live_YOUR_KEY
Content-Type: application/json请求示例
curl
bash
curl --location \
--request GET \
"https://api.seermartech.cn/v3/merchant/amazon/products/task_get/html/04170913-0696-0179-0000-707d6a06f64b" \
--header "Authorization: Bearer smt_live_YOUR_KEY" \
--header "Content-Type: application/json"GET 请求无需请求体。
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.response?.data || error.message);
});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}"
response = requests.get(
url,
headers={
"Authorization": "Bearer smt_live_YOUR_KEY",
"Content-Type": "application/json",
},
)
if response.ok:
result = response.json()
print(result)
else:
print(f"请求失败:HTTP {response.status_code}")
print(response.text)PHP
php
<?php
$taskId = '04170913-0696-0179-0000-707d6a06f64b';
$url = 'https://api.seermartech.cn/v3/merchant/amazon/products/task_get/html/' . $taskId;
$ch = curl_init($url);
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer smt_live_YOUR_KEY',
'Content-Type: application/json',
],
]);
$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if ($response === false) {
echo '请求失败:' . curl_error($ch);
} else {
echo $response;
}
curl_close($ch);响应结构
接口返回 JSON 数据,顶层 tasks 数组。每个任务对象任务状态、请求参数以及 HTML 结果。
顶层响应字段
| 字段名 | 类型 | 说明 |
|---|---|---|
version | string | 当前 API 版本。 |
status_code | integer | 通用响应状态码。完整状态码列表请参考错误码文档。 |
status_message | string | 通用提示信息。 |
time | string | 请求执行耗时,单位为秒。 |
cost | float | 平台原始 USD 成本兼容字段;人民币实扣以 X-SeerMarTech-Charge-CNY 为准。 |
tasks_count | integer | tasks 数组中的任务数量。 |
tasks_error | integer | tasks 数组中返回错误的任务数量。 |
tasks | array | 任务结果数组。 |
tasks 任务字段
| 字段名 | 类型 | 说明 |
|---|---|---|
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 | 请求 URL 路径信息。 |
data | object | 创建任务时提交的参数。 |
result | array | 任务结果数组。 |
data 字段
data含创建任务时提交的请求参数,字段取决于原始任务。
result 字段
| 字段名 | 类型 | 说明 |
|---|---|---|
keyword | string | 创建任务时提交的。返回时会对 URL 编码进行解码,字符 + 会被解码为空格。 |
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 | HTML 页面及数据。 |
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 页面。 |
响应示例
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.2800 sec.",
"cost": 0,
"result_count": 1,
"path": [
"v3",
"merchant",
"amazon",
"products",
"task_get",
"html"
],
"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>"
}
]
}
]
}
]
}任务查询流程
通常可以调用以下接口获取已完成任务列表:
http
GET /v3/merchant/amazon/products/tasks_ready然后使用返回的任务 ID 调用本接口:
http
GET /v3/merchant/amazon/products/task_get/html/$id也可以直接将任务 ID 拼接到本接口路径中查询结果。
错误处理
建议根据顶层和任务级别的 status_code 判断请求是否成功:
20000:请求或任务处理成功。status_code >= 40000:通常表示任务处理失败或发生错误。- 当
result为空时,应结合status_message记录错误原因并执行重试或异常处理。
完整状态码和提示信息请参考错误码文档。
实用场景
- 抓取亚马逊商品搜索页 HTML:保存原始页面,支持商品排名、价格、评论和库存等字段的二次解析。
- 构建商品竞品监测系统:定期获取目标对应的亚马逊页面,比较竞品展示位置、页面结构和促销信息变化。
- 验证抓取结果与解析规则:在结构化解析前保留 HTML 原文,便于排查页面改版、字段缺失或解析异常。
- 归档不同时间的商品页面:按抓取时间保存页面快,为价格趋势、促销活动和商品可见性分析提供依据。
- 批量处理任务:结合
/v3/merchant/amazon/products/tasks_ready获取已完成任务,再批量调用本接口,提高商品数据采集效率。