主题
获取 Google Hotel Info HTML 结果(按任务 ID)
接口说明
通过任务 ID 获取指定实体的 Google Hotels 页 HTML 原始。
本接口返回的是非结构化 HTML 数据,对应某个特定实体在指定 hotel_identifier、地区和语言参数下的页面结果。平台 API 会尽可能高精度地模拟请求环境,因此返回应与任务创建时对应参数下的结果一致。
你也可以使用响应中的 check_url 在浏览器无痕模式下打开,以核验返回结果是否与页面一致。
请求方式
GET https://api.seermartech.cn/v3/business_data/google/hotel_info/task_get/html/$id
计费说明
该类接口通常在创建任务时扣费,任务结果在生成后的 7 天可多次获取。
扣费以响应头 X-SeerMarTech-Charge-CNY 为准。
路径参数
| 参数名 | 类型 | 说明 |
|---|---|---|
id | string | 任务唯一标识符,UUID 格式。该 ID 可在任务创建后的 7 天 用于随时获取结果。 |
返回结果说明
接口返回 JSON 数据,顶层 tasks 数组。
顶层字段
| 字段 | 类型 | 说明 |
|---|---|---|
version | string | 当前 API 版本 |
status_code | integer | 局状态码,完整错误码请参考 /v3/appendix/errors |
status_message | string | 局状态信息 |
time | string | 请求执行时间,单位秒 |
cost | float | 本次请求总成本 |
result_count | integer | tasks 数组中的任务数量 |
tasks_error | integer | tasks 数组中返回错误的任务数量 |
tasks | array | 任务结果数组 |
tasks 数组字段
| 字段 | 类型 | 说明 |
|---|---|---|
id | string | 任务 ID,UUID 格式 |
status_code | integer | 任务级状态码,范围通常为 10000-60000,完整错误码请参考 /v3/appendix/errors |
status_message | string | 任务级状态信息 |
time | string | 任务执行时间,单位秒 |
cost | float | 当前任务成本 |
result_count | integer | result 数组中的数量 |
path | array | 请求路径 |
data | object | 任务创建时提交的原始参数 |
result | array | 结果数组 |
result 数组字段
| 字段 | 类型 | 说明 |
|---|---|---|
hotel_identifier | string | 创建任务时传的标识符,例如:CgoI-KWyzenM_MV3EAE |
location_code | integer | 创建任务时传的位置编码 |
language_code | string | 创建任务时传的语言编码 |
check_url | string | 对应搜索结果的直达链接,可用于校验结果准确性 |
datetime | string | 结果抓取时间,UTC 格式:yyyy-mm-dd hh-mm-ss +00:00 |
items_count | integer | items 数组中的结果数量 |
items | array | HTML 页面结果数组 |
items 数组字段
| 字段 | 类型 | 说明 |
|---|---|---|
page | integer | 返回的 HTML 页序号 |
date | string | HTML 页面抓取时间,UTC 格式:yyyy-mm-dd hh-mm-ss +00:00 |
html | string | 页面 HTML 原文 |
使用说明
通常推荐按以下流程调用:
- 通过创建任务接口创建采集任务;
- 再通过
/v3/business_data/google/hotel_info/tasks_ready获取已完成任务; - 最后使用本接口
/v3/business_data/google/hotel_info/task_get/html/$id按任务 ID 拉取 HTML 结果。
请求示例
curl
bash
id="09171517-0696-0242-0000-a96bc1ad0bce"
curl --location --request GET "https://api.seermartech.cn/v3/business_data/google/hotel_info/task_get/html/${id}" \
--header "Authorization: Bearer smt_live_YOUR_KEY" \
--header "Content-Type: application/json"Python
python
import requests
task_id = "02231934-2604-0066-2000-570459f04879"
url = f"https://api.seermartech.cn/v3/business_data/google/hotel_info/task_get/html/{task_id}"
headers = {
"Authorization": "Bearer smt_live_YOUR_KEY",
"Content-Type": "application/json"
}
response = requests.get(url, headers=headers)
print(response.status_code)
print(response.text)TypeScript
typescript
const taskId = '02231934-2604-0066-2000-570459f04879';
fetch(`https://api.seermartech.cn/v3/business_data/google/hotel_info/task_get/html/${taskId}`, {
method: 'GET',
headers: {
'Authorization': 'Bearer smt_live_YOUR_KEY',
'Content-Type': 'application/json'
}
})
.then(res => res.json)
.then(data => {
// 输出返回结果
console.log(data);
})
.catch(err => {
console.error(err);
});获取已完成任务后再获取结果
如果你需要批量处理已完成任务,可以查询 ready 列表,再逐个调用本接口获取 HTML 结果。
Python 示例:取 ready,再取结果
python
import requests
headers = {
"Authorization": "Bearer smt_live_YOUR_KEY",
"Content-Type": "application/json"
}
# 第一步:获取已完成任务
ready_url = "https://api.seermartech.cn/v3/business_data/google/hotel_info/tasks_ready"
ready_resp = requests.get(ready_url, headers=headers)
ready_data = ready_resp.json
results = []
if ready_data.get("status_code") == 20000:
for task_group in ready_data.get("tasks", []):
for task in task_group.get("result", []) or []:
endpoint = task.get("endpoint")
task_id = task.get("id")
# 方式 1:直接使用返回的 endpoint
if endpoint:
resp = requests.get(f"https://api.seermartech.cn{endpoint}", headers=headers)
results.append(resp.json)
# 方式 2:按任务 ID 手动拼接
# if task_id:
# resp = requests.get(
# f"https://api.seermartech.cn/v3/business_data/google/hotel_info/task_get/html/{task_id}",
# headers=headers
# )
# results.append(resp.json)
print(results)响应示例
json
{
"version": "0.1.20210430",
"status_code": 20000,
"status_message": "Ok.",
"time": "0.2257 sec.",
"cost": 0,
"tasks_count": 1,
"tasks_error": 0,
"tasks": [
{
"data": {
"se_type": "hotel_info",
"se": "google",
"api": "business_data",
"function": "hotel_info",
"language_code": "en",
"location_name": "New York,New York,United States",
"device": "desktop",
"os": "windows"
},
"result": [
{
"hotel_identifier": "CgoI-KWyzenM_MV3EAE",
"location_code": 2840,
"language_code": "en",
"check_url": "https://www.google.com/travel/hotels/entity/...",
"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>"
}
]
}
]
}
]
}状态码与异常处理
20000表示请求成功。- 当任务级
status_code大于等于40000时,通常表示该任务处理失败或返回异常。 - 建议同时检查:
- 顶层
status_code tasks[].status_codetasks[].result是否为空
完整错误码与说明请参考 /v3/appendix/errors。
注意事项
- 本接口返回的是原始 HTML,适合需要自行解析页面的场景。
- HTML 结果依赖任务创建时指定的
hotel_identifier、地区和语言参数。 - 任务结果通常可在 7 天 通过任务 ID 重复获取。
- 建议保存
id、check_url、datetime等字段,便于后续追踪与校验。
实用场景
- 抓取页原始 HTML:保留页面完整结构,便于后续自定义解析价格、设施、评价摘要等字段。
- 核验指定在不同地区的展示差异:结合不同
location_code重复采集,分析本地化排序与信息露出差别。 - 监控页变动:定期对同一
hotel_identifier拉取 HTML,识别价格模块、政策说明或卖点文案的变化。 - 构建报解析流程:将原始 HTML 接解析器,沉淀为结构化数据库,用于竞品分析或生产。
- 回溯任务结果并排查异常:通过
check_url与 HTML 原文比对,定位抓取偏差、页面变更或解析规则失效问题。