主题
根据任务 ID 获取 Google Shopping 商品 HTML 结果
本接口使用 GET 方法,通过任务 ID 获取 Google Shopping 商品结果页面的 HTML。
请求方法与路径:
text
GET https://api.seermartech.cn/v3/merchant/google/products/task_get/html/$id任务提交成功后,可在 7 天获取任务结果。系统在提交任务时计费,扣费以响应头 X-SeerMarTech-Charge-CNY 为准。
请求参数
$id 为路径参数。
| 参数 | 类型 | 说明 |
|---|---|---|
id | string | 任务唯一标识符,UUID 格式。任务提交后,可在 7 天使用该 ID 随时获取结果。 |
响应说明
接口返回 JSON 数据,结果在 tasks 数组中。
顶层字段
| 字段 | 类型 | 说明 |
|---|---|---|
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 | 任务结果数组。 |
result 数组中的字段
| 字段 | 类型 | 说明 |
|---|---|---|
keyword | string | POST 请求中提交的。返回时会对经过编码的进行解码,字符 + 会被解码为空格。 |
type | string | POST 请求中指定的搜索引擎类型。 |
se_domain | string | POST 请求中指定的搜索引擎域名。 |
location_code | integer | POST 请求中指定的地区代码。 |
language_code | string | POST 请求中指定的语言代码。 |
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 中发现的搜索结果。 |
page | integer | 返回的 HTML 页面序号。 |
date | string | HTML 页面抓取时间,UTC 格式:yyyy-mm-dd hh-mm-ss +00:00。 |
html | string | Google Shopping 结果页面的 HTML。 |
认证方式
请求需在 Authorization 请求头中携带 Bearer Token:
http
Authorization: Bearer smt_live_YOUR_KEY
Content-Type: application/jsoncURL 示例
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"PHP 示例
php
<?php
$id = '04171054-0696-0179-0000-e56ea58342c5';
$url = 'https://api.seermartech.cn/v3/merchant/google/products/task_get/html/' . $id;
$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);
if ($response === false) {
throw new RuntimeException(curl_error($ch));
}
curl_close($ch);
$result = json_decode($response, true);
print_r($result);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.response?.data || error.message);
});Python 示例
python
import requests
task_id = "04171054-0696-0179-0000-e56ea58342c5"
url = (
"https://api.seermartech.cn/v3/merchant/google/products/"
f"task_get/html/{task_id}"
)
headers = {
"Authorization": "Bearer smt_live_YOUR_KEY",
"Content-Type": "application/json",
}
response = requests.get(url, headers=headers)
response.raise_for_status()
result = response.json()
print(result)C# 示例
csharp
using System;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Threading.Tasks;
namespace SeerMarTechDemos
{
public static class Demos
{
public static async Task GetGoogleShoppingHtml()
{
var taskId = "04171054-0696-0179-0000-e56ea58342c5";
var url =
"https://api.seermartech.cn/v3/merchant/google/products/" +
$"task_get/html/{taskId}";
using var httpClient = new HttpClient();
httpClient.DefaultRequestHeaders.Authorization =
new AuthenticationHeaderValue(
"Bearer",
"smt_live_YOUR_KEY"
);
var response = await httpClient.GetAsync(url);
var responseBody = await response.Content.ReadAsStringAsync();
if (!response.IsSuccessStatusCode)
{
Console.WriteLine(
$"HTTP 错误:{(int)response.StatusCode} {response.ReasonPhrase}"
);
return;
}
Console.WriteLine(responseBody);
}
}
}响应示例
json
{
"version": "0.1.20200416",
"status_code": 20000,
"status_message": "Ok.",
"time": "0.1847 sec.",
"cost": 0,
"tasks_count": 1,
"tasks_error": 0,
"tasks": [
{
"id": "04171054-0696-0179-0000-e56ea58342c5",
"status_code": 20000,
"status_message": "Ok.",
"time": "0.1721 sec.",
"cost": 0,
"result_count": 1,
"path": [
"v3",
"merchant",
"google",
"products",
"task_get",
"html"
],
"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": [
{
"keyword": "iphone",
"type": "shopping",
"se_domain": "google.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": "<!doctype html><html>...</html>"
}
]
}
]
}状态码处理建议
status_code = 20000:请求或任务执行成功。status_code >= 40000:任务处理失败或发生错误,应结合status_message排查。- 当
result为空或tasks_error大于0时,建议记录任务 ID、状态码和错误信息,并根据业务策略重试或告警。 - 任务结果保留 7 天,请及时保存
html或完成后续解析。
实用场景
- 抓取 Google Shopping 结果页 HTML:保存指定和地区下的原始页面,便于后续解析商品排名、价格和广告展示。
- 监控竞品商品可见性:定期获取竞品对应的 Shopping 页面,评估竞品商品是否目标市场的搜索结果。
- 分析商品价格竞争力:从 HTML 中提取商品价格、促销信息和商家信息,为价格策略和选品决策提供依据。
- 构建 SEO 与电商排名档案:按、语言、地区和设备保存历史 HTML 快,分析 Google Shopping 展示变化趋势。
- 验证地区化搜索结果:对比不同
location_code、language_code、设备和操作系统下的页面,优化跨市场商品投放策略。