主题
获取 Google店搜索任务结果
本接口使用 GET 方法,通过任务 ID 获取 Google店搜索任务结果。
请求方法与路径:
http
GET https://api.seermartech.cn/v3/business_data/google/hotel_searches/task_get/$id搜索接口可返回列表,以及每家的价格、图片、评分、地理位置等信息。任务创建时,可以在 POST 请求数组中设置不同参数,以获取经过筛选的列表。
返回结果与任务创建时指定的 keyword、location 和 language 参数对应。本平台会尽可能还原指定参数下的搜索结果。返回结果中的 check_url 可用于在无痕模式下打开搜索页面,以核验数据准确性。
计费说明
- 在创建任务时计费。
- 任务创建后的 30 天,可获取该任务的结果。
- 实扣费以响应头
X-SeerMarTech-Charge-CNY为准。 - 本接口不重复收取结果查询费用。
请求参数
参数通过 URL 路径传递。
| 参数 | 类型 | 说明 |
|---|---|---|
id | string | 任务唯一标识符,UUID 格式。任务创建后 30 天均可使用该 ID 查询结果。 |
示例任务 ID:
text
09171517-0696-0242-0000-a96bc1ad0bce沙箱测试
可以使用以下沙箱地址查看该端点支持的完整字段结构:
text
https://sandbox.seermartech.cn/v3/business_data/google/hotel_searches/task_get/00000000-0000-0000-0000-000000000000沙箱响应会该端点的可用字段,但字段值为模拟数据。调用沙箱接口不会产生费用。
响应结构
接口返回 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 | 店搜索结果数组。 |
data 字段
data 字段创建任务时提交的请求参数,例如:
| 字段 | 类型 | 说明 |
|---|---|---|
se_type | string | 搜索类型,例如 hotels。 |
se | string | 搜索引擎,例如 google。 |
api | string | API 类型,例如 business_data。 |
function | string | 接口功能,例如 hotel_searches。 |
language_code | string | 语言代码。 |
location_name | string | 搜索位置名称。 |
keyword | string | 店搜索。 |
check_in | string | 住日期。 |
check_out | string | 退房日期。 |
currency | string | 价格币种。 |
adults | integer | 成人人数。 |
children | array | 儿童信息。 |
sort_by | string | 店排序方式。 |
tag | string | 用户自定义任务标签。 |
device | string | 设备类型,例如 desktop。 |
os | string | 操作系统,例如 windows。 |
result 字段
| 字段 | 类型 | 说明 |
|---|---|---|
keyword | string | POST 请求中的。返回时会对编码进行解码,例如 %## 会被还原;加号 + 会被解码为空格。为获得准确搜索结果,系统可能会自动在中追加位置名称。 |
location_code | integer | POST 请求中的位置代码。 |
language_code | string | POST 请求中的语言代码。 |
check_url | string | 搜索结果页面的直接 URL,可用于核验返回结果。 |
datetime | string | 获取结果的日期和时间,采用 UTC 格式:yyyy-mm-dd hh-mm-ss +00:00。 |
items_count | integer | items 数组中的数量。 |
items | array | 搜索结果项目数组。 |
当前 items 中支持的项目类型为:
text
hotel_search_itemhotel_search_item 字段
| 字段 | 类型 | 说明 |
|---|---|---|
type | string | 素类型,固定为 hotel_search_item。 |
hotel_identifier | string | Google 搜索中的实体唯一标识符。 |
title | string | 店名称。 |
stars | integer | 店星级,取值范围通常为 1–5;0 表示未提供星级。 |
is_paid | boolean | 是否为付费展示结果。true 表示广告,false 表示自然结果。 |
location | object | 店地理位置。 |
reviews | object | 店评价与评分信息。 |
overview_images | array | 店展示图片。 |
prices | object | 店价格信息。 |
location 字段
| 字段 | 类型 | 说明 |
|---|---|---|
latitude | float | Google Maps 中的纬度,例如 51.584091。 |
longitude | float | Google Maps 中的经度,例如 -0.31365919999999997。 |
reviews 字段
| 字段 | 类型 | 说明 |
|---|---|---|
value | float | 根据所有评价计算的平均评分。 |
votes_count | integer | 评价数量。 |
mentions | array | 店提及信息。当前始终为 null,用于保持与接口的数据结构容。 |
rating_distribution | object | 按评分等级统计的评价分布。当前始终为 null,用于保持与接口的数据结构容。 |
other_sites_reviews | array | 第三方网站上的评价信息。当前始终为 null,用于保持与接口的数据结构容。 |
prices 字段
| 字段 | 类型 | 说明 |
|---|---|---|
price | integer | 每晚价格。 |
price_without_discount | integer | 未应用折扣时的每晚原价。 |
currency | string | 价格币种。如果请求中未指定,默认使用 USD。 |
discount_text | string | 折扣说明文本。 |
check_in | string | 住日期和时间,UTC 格式:yyyy-mm-dd hh-mm-ss +00:00。 |
check_out | string | 退房日期和时间,UTC 格式:yyyy-mm-dd hh-mm-ss +00:00。 |
visitors | integer | 对应该价格的人数。 |
items | array | 价格明细项目。当前始终为 null,用于保持与接口的数据结构容。 |
错误处理
建议根据以下字段实现错误处理逻辑:
- 顶层
status_code:判断整个请求是否成功。 - 任务级
tasks[].status_code:判断指定任务是否成功。 status_message:获取错误或状态说明。tasks_error:判断返回错误的任务数量。- 当任务级状态码表示错误,或
result为空时,应记录任务 ID 和状态信息,并根据业务需要进行重试或人工检查。
请求示例
cURL
bash
id="09171517-0696-0242-0000-a96bc1ad0bce"
curl --location --request GET \
"https://api.seermartech.cn/v3/business_data/google/hotel_searches/task_get/${id}" \
--header "Authorization: Bearer smt_live_YOUR_KEY" \
--header "Content-Type: application/json"TypeScript
typescript
import axios from "axios";
const taskId = "02231934-2604-0066-2000-570459f04879";
axios
.get(
`https://api.seermartech.cn/v3/business_data/google/hotel_searches/task_get/${taskId}`,
{
headers: {
Authorization: "Bearer smt_live_YOUR_KEY",
"Content-Type": "application/json",
},
}
)
.then((response) => {
// 处理任务结果
console.log(response.data);
})
.catch((error) => {
// 处理 HTTP 或接口错误
console.error(error.response?.data || error.message);
});Python
python
import requests
task_id = "09171517-0696-0242-0000-a96bc1ad0bce"
url = (
"https://api.seermartech.cn/v3/business_data/google/"
f"hotel_searches/task_get/{task_id}"
)
headers = {
"Authorization": "Bearer smt_live_YOUR_KEY",
"Content-Type": "application/json",
}
response = requests.get(url, headers=headers, timeout=60)
response.raise_for_status()
data = response.json()
if data.get("status_code") == 20000:
print(data)
else:
print(
"请求失败:",
data.get("status_code"),
data.get("status_message"),
)响应示例
json
{
"version": "0.1.20220720",
"status_code": 20000,
"status_message": "Ok.",
"time": "0.0739 sec.",
"cost": 0,
"tasks_count": 1,
"tasks_error": 0,
"tasks": [
{
"id": "09171517-0696-0242-0000-a96bc1ad0bce",
"status_code": 20000,
"status_message": "Ok.",
"time": "0.0501 sec.",
"cost": 0,
"result_count": 1,
"path": [
"v3",
"business_data",
"google",
"hotel_searches",
"task_get",
"09171517-0696-0242-0000-a96bc1ad0bce"
],
"data": {
"se_type": "hotels",
"se": "google",
"api": "business_data",
"function": "hotel_searches",
"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": [],
"sort_by": "highest_rating",
"tag": "example",
"device": "desktop",
"os": "windows"
},
"result": [
{
"keyword": "cheap hotel New York,New York,United States",
"location_code": 2840,
"language_code": "en",
"check_url": "https://www.google.com/travel/search?q=cheap%20hotel",
"datetime": "2023-06-01 12:00:00 +00:00",
"items_count": 2,
"items": [
{
"type": "hotel_search_item",
"hotel_identifier": "ChoIpLCr95T4krHzARoNL2cvMTFiNjM2N25wZhAB",
"title": "NobleDen Hotel",
"stars": 3,
"is_paid": false,
"location": {
"latitude": 40.71936,
"longitude": -73.99677
},
"reviews": {
"value": 4.7,
"votes_count": 458,
"mentions": null,
"rating_distribution": null,
"other_sites_reviews": null
},
"overview_images": [],
"prices": {
"price": 357,
"price_without_discount": null,
"currency": "USD",
"discount_text": null,
"check_in": "2023-06-01 00:00:00 +00:00",
"check_out": "2023-06-30 00:00:00 +00:00",
"visitors": 3,
"items": null
}
},
{
"type": "hotel_search_item",
"hotel_identifier": "ChkI-JHp7LjVo4V7Gg0vZy8xMWYzYnhndDA5EAE",
"title": "Artezen Hotel",
"stars": 4,
"is_paid": false,
"location": {
"latitude": 40.7096,
"longitude": -74.00872
},
"reviews": {
"value": 4.7,
"votes_count": 400,
"mentions": null,
"rating_distribution": null,
"other_sites_reviews": null
},
"overview_images": [],
"prices": {
"price": 275,
"price_without_discount": null,
"currency": "USD",
"discount_text": null,
"check_in": "2023-06-01 00:00:00 +00:00",
"check_out": "2023-06-30 00:00:00 +00:00",
"visitors": 3,
"items": null
}
}
]
}
]
}
]
}实用场景
- 核验搜索结果:通过
check_url对指定、地点和日期的搜索页面,提升数据采集与报告输出的可信度。 - 比较价格与折扣:读取
prices中的当前价格、原价、币种和折扣信息,支持平台或站进行价格对比。 - 筛选高评分:结合
stars、reviews.value和votes_count,构建按星级、评分及评价数量筛选的推荐列表。 - 分析本地搜索可见度:根据
is_paid区分广告与自然结果,评估在不同和地点下的搜索。 - 生成区域数据报告:利用名称、经纬度、价格和评价数据,制作城市住宿市场、竞品及目的地分析报告。