Skip to content

获取 Google店搜索任务结果

本接口使用 GET 方法,通过任务 ID 获取 Google店搜索任务结果。

请求方法与路径:

http
GET https://api.seermartech.cn/v3/business_data/google/hotel_searches/task_get/$id

搜索接口可返回列表,以及每家的价格、图片、评分、地理位置等信息。任务创建时,可以在 POST 请求数组中设置不同参数,以获取经过筛选的列表。

返回结果与任务创建时指定的 keywordlocationlanguage 参数对应。本平台会尽可能还原指定参数下的搜索结果。返回结果中的 check_url 可用于在无痕模式下打开搜索页面,以核验数据准确性。

计费说明

  • 在创建任务时计费。
  • 任务创建后的 30 天,可获取该任务的结果。
  • 实扣费以响应头 X-SeerMarTech-Charge-CNY 为准。
  • 本接口不重复收取结果查询费用。

请求参数

参数通过 URL 路径传递。

参数类型说明
idstring任务唯一标识符,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 数组。

顶层字段

字段类型说明
versionstring当前 API 版本。
status_codeinteger通用响应状态码。
status_messagestring通用状态说明。
timestring请求执行耗时,单位为秒。
costfloat平台原始 USD 成本兼容字段;人民币实扣以 X-SeerMarTech-Charge-CNY 为准。
tasks_countintegertasks 数组中的任务数量。
tasks_errorintegertasks 数组中返回错误的任务数量。
tasksarray任务结果数组。

tasks 数组中的字段

字段类型说明
idstring任务唯一标识符,UUID 格式。
status_codeinteger当前任务的状态码,通常位于 1000060000 范围。
status_messagestring当前任务的状态说明。
timestring任务执行耗时,单位为秒。
costfloat平台原始 USD 成本兼容字段;人民币实扣以 X-SeerMarTech-Charge-CNY 为准。
result_countintegerresult 数组中的数量。
patharray请求 URL 路径信息。
dataobject创建任务时提交的参数。
resultarray店搜索结果数组。

data 字段

data 字段创建任务时提交的请求参数,例如:

字段类型说明
se_typestring搜索类型,例如 hotels
sestring搜索引擎,例如 google
apistringAPI 类型,例如 business_data
functionstring接口功能,例如 hotel_searches
language_codestring语言代码。
location_namestring搜索位置名称。
keywordstring店搜索。
check_instring住日期。
check_outstring退房日期。
currencystring价格币种。
adultsinteger成人人数。
childrenarray儿童信息。
sort_bystring店排序方式。
tagstring用户自定义任务标签。
devicestring设备类型,例如 desktop
osstring操作系统,例如 windows

result 字段

字段类型说明
keywordstringPOST 请求中的。返回时会对编码进行解码,例如 %## 会被还原;加号 + 会被解码为空格。为获得准确搜索结果,系统可能会自动在中追加位置名称。
location_codeintegerPOST 请求中的位置代码。
language_codestringPOST 请求中的语言代码。
check_urlstring搜索结果页面的直接 URL,可用于核验返回结果。
datetimestring获取结果的日期和时间,采用 UTC 格式:yyyy-mm-dd hh-mm-ss +00:00
items_countintegeritems 数组中的数量。
itemsarray搜索结果项目数组。

当前 items 中支持的项目类型为:

text
hotel_search_item

hotel_search_item 字段

字段类型说明
typestring素类型,固定为 hotel_search_item
hotel_identifierstringGoogle 搜索中的实体唯一标识符。
titlestring店名称。
starsinteger店星级,取值范围通常为 150 表示未提供星级。
is_paidboolean是否为付费展示结果。true 表示广告,false 表示自然结果。
locationobject店地理位置。
reviewsobject店评价与评分信息。
overview_imagesarray店展示图片。
pricesobject店价格信息。

location 字段

字段类型说明
latitudefloatGoogle Maps 中的纬度,例如 51.584091
longitudefloatGoogle Maps 中的经度,例如 -0.31365919999999997

reviews 字段

字段类型说明
valuefloat根据所有评价计算的平均评分。
votes_countinteger评价数量。
mentionsarray店提及信息。当前始终为 null,用于保持与接口的数据结构容。
rating_distributionobject按评分等级统计的评价分布。当前始终为 null,用于保持与接口的数据结构容。
other_sites_reviewsarray第三方网站上的评价信息。当前始终为 null,用于保持与接口的数据结构容。

prices 字段

字段类型说明
priceinteger每晚价格。
price_without_discountinteger未应用折扣时的每晚原价。
currencystring价格币种。如果请求中未指定,默认使用 USD
discount_textstring折扣说明文本。
check_instring住日期和时间,UTC 格式:yyyy-mm-dd hh-mm-ss +00:00
check_outstring退房日期和时间,UTC 格式:yyyy-mm-dd hh-mm-ss +00:00
visitorsinteger对应该价格的人数。
itemsarray价格明细项目。当前始终为 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 中的当前价格、原价、币种和折扣信息,支持平台或站进行价格对比。
  • 筛选高评分:结合 starsreviews.valuevotes_count,构建按星级、评分及评价数量筛选的推荐列表。
  • 分析本地搜索可见度:根据 is_paid 区分广告与自然结果,评估在不同和地点下的搜索。
  • 生成区域数据报告:利用名称、经纬度、价格和评价数据,制作城市住宿市场、竞品及目的地分析报告。

统一入口:官网 · LLM API · 控制台