旅游:酒店
抓取 Google Travel:酒店结果,并支持住客人数、日期和星级筛选。灵活的 API 集成,具备完整的参数选项。
该 google_travel_hotels 数据源旨在获取 Google Travel 服务的酒店搜索结果。
为了确保此服务的最佳利用,请在请求中包含 "render": "html" 参数。
请求示例
在此示例中,我们发出请求以获取 2酒店可用性结果的第 nd 页 2 成年客人之间 2023-10-01 和 2023-10-10 为 2 到 4-星级巴黎酒店,来自 google.com.
curl 'https://realtime.oxylabs.io/v1/queries' \\
--user 'USERNAME:PASSWORD' \\
-H 'Content-Type: application/json' \\
-d '{
"source": "google_travel_hotels",
"start_page": 2,
"query": "hotels in Paris",
"render": "html",
"parse": true,
"context": [
{"key": "adults", "value": 2},
{"key": "hotel_dates", "value": "2023-10-01,2023-10-10"},
{"key": "hotel_classes", "value": [2, 3, 4]}
]
}'import requests
from pprint import pprint
# 结构化载荷。
payload = {
"source": "google_travel_hotels",
"query": "hotels in Paris",
"start_page": 2,
"render": "html",
"parse": True,
"context": [
{
"key": "adults",
"value": 1
},
{
"key": "hotel_dates",
"value": "2023-10-01,2023-10-10"
},
{
"key": "hotel_classes",
"value": [2, 3, 4]
}
]
}
# 获取响应。
response = requests.request(
'POST',
'https://realtime.oxylabs.io/v1/queries',
auth=('USERNAME', 'PASSWORD'),
json=payload,
)
# Print prettified response to stdout.
pprint(response.json())我们在示例中使用同步 Realtime 集成方法。如果您想使用 Proxy Endpoint 或异步 Push-Pull 集成,请参阅 集成方法 部分。
请求参数
通用
source
设置爬虫。使用 google_travel_hotels.
–
查询
请求的搜索词。 "query": "hotels" 将在给定的 geo_location.
"query": "hotels in <Location>" 将返回 <Location>.(例如 "query": "hotels in Paris" 将列出巴黎的酒店,无论 geo_location)
–
- 必填参数
本地化
使搜索结果适配特定地理位置和语言。
分页
start_page
起始页码。
1
筛选
用于定制和细化搜索上下文的高级选项。
context:adults
成年客人数量
2
context:children
儿童客人数量
-
context:
hotel_classes
按酒店星级筛选结果。您可以指定介于 2 和 5之间的一个或多个值。示例: [3,4]
-
context:
hotel_dates
酒店入住日期,起止。示例: 2023-07-12,2023-07-13
-
所有 context 参数都应在 context 数组中,作为带有 键 和 值 键值对:
结构化数据
网页爬虫API 可以提取结果 HTML,或包含结果页面中各种元素结构化数据的 JSON 响应。
输出字典
下表列出了我们解析的每个顶级元素,包括其描述和数据类型。
url
Google Travel 酒店搜索页面的 URL。
字符串
page
搜索结果的当前页码。
整数
last_visible_page
结果页中可见的最大页码。
整数
results
包含解析后的酒店搜索结果的对象。
对象
results.offers
针对该查询返回的酒店优惠列表。包括 pos, 姓名, description, property_token, hotel_class, rating, deal, eco_certified, pricing, check_in_time, check_out_time, coordinates, amenities, images, nearby_places, website_url, details_url, reviews_url.
数组
results.overview
有关搜索结果的总体信息。包括 国家, language, total_results.
对象
results.pagination
有关当前结果页的详细信息。包括 current_from, current_to.
对象
创建时间
抓取任务创建时的时间戳。
时间戳
更新时间
抓取任务完成时的时间戳。
时间戳
任务ID
与抓取任务关联的任务ID。
字符串
最后更新于
这有帮助吗?

