Skip to content

按任务 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 为准。
  • 本接口本身不重复收取结果查询费用。

请求参数

路径参数

参数名类型说明
idstring任务唯一标识,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 结果。

顶层响应字段

字段名类型说明
versionstring当前 API 版本。
status_codeinteger通用响应状态码。完整状态码列表请参考错误码文档。
status_messagestring通用提示信息。
timestring请求执行耗时,单位为秒。
costfloat平台原始 USD 成本兼容字段;人民币实扣以 X-SeerMarTech-Charge-CNY 为准。
tasks_countintegertasks 数组中的任务数量。
tasks_errorintegertasks 数组中返回错误的任务数量。
tasksarray任务结果数组。

tasks 任务字段

字段名类型说明
idstring任务唯一标识,UUID 格式。
status_codeinteger当前任务的状态码,通常位于 1000060000 范围。
status_messagestring当前任务的状态说明。
timestring任务执行耗时,单位为秒。
costfloat平台原始 USD 成本兼容字段;人民币实扣以 X-SeerMarTech-Charge-CNY 为准。
result_countintegerresult 数组中的结果数量。
patharray请求 URL 路径信息。
dataobject创建任务时提交的参数。
resultarray任务结果数组。

data 字段

data含创建任务时提交的请求参数,字段取决于原始任务。

result 字段

字段名类型说明
keywordstring创建任务时提交的。返回时会对 URL 编码进行解码,字符 + 会被解码为空格。
typestring创建任务时提交的搜索类型。
se_domainstring创建任务时提交的搜索引擎域名。
location_codeinteger创建任务时提交的地区代码。
language_codestring创建任务时提交的语言代码。
datetimestring获取结果的日期和时间,使用 UTC 格式:yyyy-mm-dd hh-mm-ss +00:00。示例:2019-11-15 12:57:46 +00:00
items_countintegeritems 数组中的结果数量。
itemsarrayHTML 页面及数据。

items 字段

字段名类型说明
pageinteger返回 HTML 页面的序号。
datestringHTML 页面抓取时间,使用 UTC 格式:yyyy-mm-dd hh-mm-ss +00:00。示例:2019-11-15 12:57:46 +00:00
htmlstring抓取到的 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 获取已完成任务,再批量调用本接口,提高商品数据采集效率。

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