主题
设置 Google店搜索任务
POST /v3/business_data/google/hotel_searches/task_post
本接口使用 POST 方法创建 Google店搜索任务:
POST https://api.seermartech.cn/v3/business_data/google/hotel_searches/task_post
搜索接口根据、指定地点和语言,返回 Google店搜索结果及信息。地点和语言可分别通过以下接口获取:
- 地点列表:
/v3/business_data/google/locations - 语言列表:
/v3/business_data/google/languages
计费与请求限制
创建任务会产生费用。示例响应中的任务费用为 0.00075 USD,按参考汇率折算后约为 ¥0.0054 / 次。扣费以响应头 X-SeerMarTech-Charge-CNY 为准。
请求体使用 UTF-8 编码的 JSON 格式,并且整体为 JSON 数组:
json
[
{
"location_code": 2840,
"language_code": "en",
"keyword": "cheap hotel"
}
]请求限制:
平台限流以认证说明中的 30/60/120 次/分钟规则为准。
- 每次请求最多 100 个任务。 -过 100 个任务的部分将返回错误码
40006。 - 创建任务后,可使用返回的任务
id查询结果。 - 如果设置了
postback_url或pingback_url,任务完成后本平台会主动发送通知。 - 如果回调服务器在 10 秒未返回响应,连接将因时中断,任务会转任务就绪列表。
请求参数
| 参数 | 类型 | 填 | 说明 |
|---|---|---|---|
keyword | string | 否 | 店搜索。未设置时,返回指定地点中找到的列表。最多 700 个字符。所有 %## 编码会被解码,字符 + 会被解码为空格。如需在中使用 %,请传 %25。为提高搜索准确性,指定的地点名称通常会自动追加到后。 |
priority | integer | 否 | 任务优级:1 为普通优级,默认值;2 为高优级。高优级任务会产生额外费用。 |
location_name | string | 条件填 | 搜索引擎地点的完整名称。未指定 location_code 或 location_coordinate 时填。使用该参数后,无需再传两个地点参数。示例:London,England,United Kingdom。地点名称会自动追加到后。 |
location_code | integer | 条件填 | 搜索引擎地点代码。未指定 location_name 或 location_coordinate 时填。示例:2840。 |
location_coordinate | string | 条件填 | 地点 GPS 坐标,格式为 "纬度,经度",经纬度最多保留 7 位小数。未指定 location_name 或 location_code 时填。使用坐标时,搜索将在距离该坐标最近的点进行。示例:53.476225,-2.243572。 |
search_this_area | boolean | 否 | 是否显示当前地图区域的。可选值为 true 或 false,默认值为 true。设为 false 后,将区域搜索模式,地点名称也不会自动追加到后。 |
language_name | string | 条件填 | 搜索引擎语言的完整名称。未指定 language_code 时填。示例:English。 |
language_code | string | 条件填 | 搜索引擎语言代码。未指定 language_name 时填。示例:en。 |
depth | integer | 否 | 解析结果数量,默认值为 18,最大值为 140。计费按每 18 条自然结果计算,与响应中是否付费列表无。当 depth 大于 18 且 Google Hotels 返回 18 条结果时,可能产生额外费用。如果返回结果少于指定数量,差额费用会自动退还至账户余额。 |
check_in | string | 否 | 住日期,格式为 yyyy-mm-dd。未指定时默认为明天。日期不能早于当天。示例:2019-01-15。 |
check_out | string | 否 | 退房日期,格式为 yyyy-mm-dd。未指定时默认为后天。日期晚于 check_in,且与退房之间的间隔不能 30 天。示例:2019-01-15。 |
currency | string | 否 | 价格货币代码。示例:USD。 |
adults | integer | 否 | 成人数量,默认值为 2。成人与儿童总人数最多为 6 人。示例:1。 |
children | array | 否 | 儿童年龄数组。不传时表示不儿童。儿童年龄范围为 0 至 17 岁。成人与儿童总人数最多为 6 人。 |
stars | array | 否 | 店星级筛选。传 [5] 可获取五星级。 |
min_rating | float | 否 | 最低住客评分。示例:2.5。 |
sort_by | string | 否 | 结果排序方式。可选值:relevance(性,默认值)、lowest_price(最低价格)、highest_rating(最高评分)、most_reviewed(评论数最多)。 |
min_price | integer | 否 | 每晚最低价格。货币由 currency 参数决定。示例:100。 |
max_price | integer | 否 | 每晚最高价格。货币由 currency 参数决定。示例:600。 |
free_cancellation | boolean | 否 | 是否返回支持取消预订的。默认值为 false。 |
is_vacation_rentals | boolean | 否 | 是否搜索度假租赁房源而非。默认值为 false。 |
amenities | array | 否 | 店设施筛选。 |
tag | string | 否 | 用户自定义任务标识,最多 255 个字符。该值会原样出现在响应 data 对象中,可用于任务和结果。 |
postback_url | string | 否 | 任务完成后接收结果的 URL。本平台会向该地址发送 POST 请求,结果使用 gzip 压缩。URL 中可使用 $id 和 $tag 占位符,本平台发送请求前会替换为任务 ID 和经过 URL 编码的标签值。 |
pingback_url | string | 否 | 任务完成后的通知 URL。本平台会向该地址发送 GET 请求,并替换 $id 和 $tag 占位符。 |
地点参数互斥
以下三个参数至少提供一个,且建议只使用一个:
location_namelocation_codelocation_coordinate
可通过以下接口获取可用地点:
GET https://api.seermartech.cn/v3/business_data/google/locations
语言参数互斥
以下两个参数至少提供一个,且建议只使用一个:
language_namelanguage_code
可通过以下接口获取可用语言:
GET https://api.seermartech.cn/v3/business_data/google/languages
children 示例
一名 14 岁儿童:
json
[14]一名 13 岁儿童和一名 8 岁儿童:
json
[13, 8]amenities 可选值
json
[
"air_conditioning",
"all_inclusive_available",
"bar",
"free_breakfast",
"fitness_center",
"kid_friendly",
"free_parking",
"pets_allowed",
"pool",
"restaurant",
"room_service",
"spa",
"free_wifi",
"parking",
"indoor_pool",
"outdoor_pool",
"wheelchair_accessible",
"beach_access"
]回调 URL
postback_url 示例:
text
https://your-server.com/postbackscript?id=$id&tag=$tagpingback_url 示例:
text
https://your-server.com/pingscript?id=$id&tag=$tag回调 URL 中的特殊字符会进行 URL 编码。例如,# 会编码为 %23。
curl 请求示例
bash
curl --location --request POST \
"https://api.seermartech.cn/v3/business_data/google/hotel_searches/task_post" \
--header "Authorization: Bearer smt_live_YOUR_KEY" \
--header "Content-Type: application/json" \
--data-raw '[
{
"location_code": 1023191,
"language_code": "en",
"keyword": "cheap hotel"
},
{
"location_name": "New York,New York,United States",
"language_name": "English",
"keyword": "cheap hotel",
"check_in": "2023-06-01",
"check_out": "2023-06-30",
"currency": "USD",
"adults": 2,
"children": [13, 8],
"sort_by": "highest_rating",
"pingback_url": "https://your-server.com/pingscript?id=$id&tag=$tag",
"priority": 2,
"tag": "example"
}
]'Python 请求示例
python
import requests
url = "https://api.seermartech.cn/v3/business_data/google/hotel_searches/task_post"
headers = {
"Authorization": "Bearer smt_live_YOUR_KEY",
"Content-Type": "application/json",
}
post_data = [
{
"location_code": 1023191,
"language_code": "en",
"keyword": "cheap hotel",
},
{
"location_name": "New York,New York,United States",
"language_name": "English",
"keyword": "cheap hotel",
"check_in": "2023-06-01",
"check_out": "2023-06-30",
"currency": "USD",
"adults": 2,
"children": [13, 8],
"sort_by": "highest_rating",
"priority": 2,
"tag": "example",
"pingback_url": "https://your-server.com/pingscript?id=$id&tag=$tag",
},
]
response = requests.post(url, headers=headers, json=post_data)
result = response.json()
if result.get("status_code") == 20000:
print(result)
else:
print(
"请求失败,错误码:{},错误信息:{}".format(
result.get("status_code"),
result.get("status_message"),
)
)TypeScript 请求示例
typescript
import axios from "axios";
const postData = [
{
location_code: 1023191,
language_code: "en",
keyword: "cheap hotel",
},
{
location_name: "New York,New York,United States",
language_name: "English",
keyword: "cheap hotel",
check_in: "2023-06-01",
check_out: "2023-06-30",
currency: "USD",
adults: 2,
children: [13, 8],
sort_by: "highest_rating",
pingback_url: "https://your-server.com/pingscript?id=$id&tag=$tag",
priority: 2,
tag: "example",
},
];
axios
.post(
"https://api.seermartech.cn/v3/business_data/google/hotel_searches/task_post",
postData,
{
headers: {
Authorization: "Bearer smt_live_YOUR_KEY",
"Content-Type": "application/json",
},
}
)
.then((response) => {
const result = response.data;
if (result.status_code === 20000) {
console.log(result);
} else {
console.error(
`请求失败,错误码:${result.status_code},错误信息:${result.status_message}`
);
}
})
.catch((error) => {
console.error(error);
});响应说明
接口返回 JSON 数据 tasks 数组。创建任务成功后,任务的 result 通常为 null,需要使用任务 ID 查询结果,或回调通知。
| 字段 | 类型 | 说明 |
|---|---|---|
version | string | 当前 API 版本。 |
status_code | integer | 请求整体状态码。完整错误码列表请参考 /v3/appendix/errors。 |
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 数组中的结果数量。创建任务接口通常为 0。 |
path | array | 请求 URL 路径信息。 |
data | object | 创建任务时提交的参数,以及系统补的任务数据。 |
result | array/null | 任务结果数组。创建任务成功后通常为 null。 |
响应示例
json
{
"version": "0.1.20220720",
"status_code": 20000,
"status_message": "Ok.",
"time": "0.1620 sec.",
"cost": 0.00075,
"tasks_count": 1,
"tasks_error": 0,
"tasks": [
{
"id": "11111111-2222-3333-4444-555555555555",
"status_code": 20100,
"status_message": "Task Created.",
"time": "0.0340 sec.",
"cost": 0.00075,
"result_count": 0,
"path": [
"v3",
"business_data",
"google",
"hotel_searches",
"task_post"
],
"data": {
"api": "business_data",
"function": "hotel_searches",
"se": "google",
"language_code": "en",
"location_name": "New York,New York,United States",
"keyword": "cheap hotel",
"check_in": "2023-06-01",
"check_out": "2023-06-30",
"currency": "USD",
"adults": 2,
"children": [13, 8],
"sort_by": "highest_rating",
"tag": "example",
"se_type": "hotels",
"device": "desktop",
"os": "windows"
},
"result": null
}
]
}状态码与错误处理
20000:请求成功。40006:单次请求提交的任务数量 100 个。- 任务级状态码可能位于
10000至60000范围。 - 建议客户端同时检查顶层
status_code、tasks_error以及每个任务中的status_code。 - 完整错误码列表请参考
/v3/appendix/errors。
实用场景
- 监控目标城市价格:按地点、日期和退房日期批量采集价格,为产品定价和竞品监控提供依据。
- 筛选高评分资源:使用
min_rating、stars和sort_by筛选优质,支持推荐页和本地建设。 - 分析搜索需求:围绕“便宜”“带泳池”等采集 Google店结果,评估不同目的地的搜索竞争度。
- 比较取消政策与设施:结合
free_cancellation和amenities参数筛选,套餐设计和用户需求分析。 - 追踪度假租赁市场:将
is_vacation_rentals设置为true,采集度假租赁房源信息,支持与民宿市场的 SEO 竞品研究。