主题
business_data/tripadvisor/search/task_post:创建 Tripadvisor 商家搜索任务
POST /v3/business_data/tripadvisor/search/task_post
本接口使用 POST 方法,路径为:
/v3/business_data/tripadvisor/search/task_post
用于根据指定和地区,创建 Tripadvisor 商家搜索任务,并返回符合条件的商家资料。可以是商家类别、名称或知名地点。
> 计费说明
> 每返回最多 30 条搜索结果计费一次。例如,当 depth 设置为 31 时,系统可能按 60 条结果计费。扣费以响应头 X-SeerMarTech-Charge-CNY 为准。
请求说明
- 请求方法:
POST - 请求地址:
https://api.seermartech.cn/v3/business_data/tripadvisor/search/task_post - 请求格式:JSON
- 请求体格式:JSON 数组,最多 100 个任务对象 平台限流以认证说明中的 30/60/120 次/分钟规则为准
- 每次请求 100 个任务时,出部分将返回错误码
40006
任务创建成功后,可以通过返回的任务 id 查询结果。也可以在请求中 postback_url 或 pingback_url,任务完成后由本平台主动通知。
如果通知目标服务器在 10 秒未返回响应,连接将因时中断,任务会转移到任务就绪列表中。
请求参数
请求体中的每个数组代表一个任务。
| 参数 | 类型 | 填 | 说明 |
|---|---|---|---|
keyword | string | 是 | 搜索。应表示商家类别、名称或知名地点。最长 700 个字符。参数中的 %## 将被解码,字符 + 将被解码为空格。如需在中使用 %,请编码为 %25。 |
location_name | string | 条件填 | 搜索地区的完整名称。未指定 location_code 时填。 |
location_code | integer | 条件填 | 搜索地区代码。未指定 location_name 时填。 |
priority | integer | 否 | 任务优级。1:普通优级,默认值;2:高优级。高优级任务会产生额外费用。 |
depth | integer | 否 | 需要返回的搜索结果数量。建议设置为 30 的倍数,因为系统按每批 30 条结果处理。默认值为 30,最大值为 210。 |
tag | string | 否 | 用户自定义任务标识,最长 255 个字符。可用于将任务与结果进行匹。指定的值会在响应任务的 data 对象中返回。 |
postback_url | string | 否 | 任务完成后接收结果的 URL。本平台会向该地址发送结果的 POST 请求,使用 gzip 压缩。 |
pingback_url | string | 否 | 任务完成通知地址。本平台会向该地址发送 GET 请求。 |
location_name 与 location_code
location_name 和 location_code 至少指定一个。
可通过以下接口获取可用地区及代码:
GET https://api.seermartech.cn/v3/business_data/tripadvisor/locations
示例:
text
location_name: London,England,United Kingdom
location_code: 1003854postback_url 与 pingback_url
URL 中可以使用以下变量:
$id:任务完成后替换为任务 ID$tag:任务完成后替换为经过 URL 编码的tag值
示例:
text
https://your-server.com/postbackscript?id=$id
https://your-server.com/postbackscript?id=$id&tag=$tagtext
https://your-server.com/pingscript?id=$id
https://your-server.com/pingscript?id=$id&tag=$tagpostback_url 和 pingback_url 中的特殊字符会进行 URL 编码,例如 # 会编码为 %23。
计费
任务费用由以下因素决定:
- 创建任务产生的基础费用;
- 返回的搜索结果数量;
priority设置为2时产生的高优级附加费用;depth跨越多个 30 条结果区间时产生的额外费用。
建议将 depth 设置为 30、60、90 等 30 的倍数,以便控制结果数量和费用。
扣费以响应头 X-SeerMarTech-Charge-CNY 为准。
请求示例
curl
bash
curl --location --request POST \
"https://api.seermartech.cn/v3/business_data/tripadvisor/search/task_post" \
--header "Authorization: Bearer smt_live_YOUR_KEY" \
--header "Content-Type: application/json" \
--data-raw '[
{
"keyword": "pizza restaurant",
"location_code": 1003854
},
{
"keyword": "pizza restaurant",
"location_code": 1003854,
"priority": 2,
"depth": 30,
"tag": "some_string_123",
"pingback_url": "https://your-server.com/pingscript?id=$id&tag=$tag"
},
{
"keyword": "pizza restaurant",
"location_code": 1003854,
"postback_url": "https://your-server.com/postbackscript"
}
]'TypeScript
typescript
import axios from "axios";
const postData = [
{
keyword: "pizza restaurant",
location_code: 1003854,
depth: 30
},
{
keyword: "pizza restaurant",
location_code: 1003854,
priority: 2,
tag: "some_string_123",
pingback_url: "https://your-server.com/pingscript?id=$id&tag=$tag"
},
{
keyword: "pizza restaurant",
location_code: 1003854,
postback_url: "https://your-server.com/postbackscript"
}
];
axios({
method: "post",
url: "https://api.seermartech.cn/v3/business_data/tripadvisor/search/task_post",
headers: {
Authorization: "Bearer smt_live_YOUR_KEY",
"Content-Type": "application/json"
},
data: postData
})
.then((response) => {
// 处理任务创建结果
console.log(response.data);
})
.catch((error) => {
// 处理请求错误
console.error(error.response?.data || error.message);
});Python
python
import requests
url = "https://api.seermartech.cn/v3/business_data/tripadvisor/search/task_post"
headers = {
"Authorization": "Bearer smt_live_YOUR_KEY",
"Content-Type": "application/json"
}
post_data = [
{
"keyword": "pizza restaurant",
"location_code": 1003854
},
{
"keyword": "pizza restaurant",
"location_code": 1003854,
"priority": 2,
"tag": "some_string_123",
"pingback_url": "https://your-server.com/pingscript?id=$id&tag=$tag"
},
{
"keyword": "pizza restaurant",
"location_code": 1003854,
"postback_url": "https://your-server.com/postbackscript"
}
]
response = requests.post(
url,
headers=headers,
json=post_data,
timeout=30
)
result = response.json()
if result.get("status_code") == 20000:
# 处理任务创建结果
print(result)
else:
print(
"请求失败。错误码:{},错误信息:{}".format(
result.get("status_code"),
result.get("status_message")
)
)响应结构
接口返回 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 | 请求路径信息。 |
data | object | 创建任务时提交的参数。 |
result | array/null | 任务结果数组。创建任务接口返回时通常为 null。 |
响应示例
json
{
"version": "0.1.20220216",
"status_code": 20000,
"status_message": "Ok.",
"time": "0.0847 sec.",
"cost": 0.00075,
"tasks_count": 1,
"tasks_error": 0,
"tasks": [
{
"id": " Johannes-1234567890",
"status_code": 20100,
"status_message": "Task Created.",
"time": "0.0123 sec.",
"cost": 0.00075,
"result_count": 0,
"path": [
"v3",
"business_data",
"tripadvisor",
"search",
"task_post"
],
"data": {
"api": "business_data",
"function": "search",
"keyword": "pizza",
"location_code": 1003854,
"se_type": "organic",
"se": "tripadvisor",
"device": "desktop",
"os": "windows"
},
"result": null
}
]
}> 示例中的 id 用于展示字段结构,响应会返回系统生成的 UUID。
状态码与错误处理
20000:请求成功。40006:单次请求中的任务数量 100 个,出限制的任务会返回此错误。- 任务级状态码用于表示每个任务的创建或处理状态。
- 建议客户端同时检查顶层
status_code、tasks_error以及每个任务的status_code,并针对失败任务实现重试或记录机制。
实用场景
- 检索指定城市的餐饮商家,批量获取目标地区的商家资料,为本地 SEO 和竞品研究提供数据。
- 对比不同下的商家覆盖,分析某个商家类别在 Tripadvisor 搜索结果中的可见度。
- 批量监测竞争对手商家,按地区和创建任务,支持门店拓展与竞品报分析。
- 使用
depth获取多层搜索结果,扩大样本范围,用于商家名单构建、市场规模评估和区域机会发现。 - 通过
postback_url或pingback_url接收异步通知,将任务结果自动接数据仓库、报表系统或 SEO 监控流程。