google_travel_hotels 模板用于获取 Google Travel Hotels 的搜索结果。
输入参数
Google Travel Hotels 模板可用的请求参数:| 参数 | 类型 | 必需 | 描述 |
|---|---|---|---|
target | string | ✅ | 目标类型必须设置为 google_travel_hotels。 |
query | string | ✅ | 搜索查询。 |
headless | string | html 值启用 JavaScript 渲染。了解更多。png 值启用截图响应。了解更多。 | |
parse | boolean | 设置为 true 时自动解析结果。默认值为 false。 | |
geo | string | 设置提交查询时使用的国家。了解更多。 | |
locale | string | 设置值以更改 Google 搜索页面的网页界面语言。了解更多。 | |
device_type | string | 指定设备类型和浏览器。了解更多。 | |
xhr | boolean | 设置为 true 以检索 XHR 和 fetch 请求列表。了解更多。默认值为 false。 | |
markdown | boolean | 设置为 true 以接收 Markdown 响应。了解更多。默认值为 false。 |
请求示例
# 更新 'TOKEN VALUE' 为您的授权令牌
curl --request 'POST' \
--url 'https://scraper-api.decodo.com/v2/scrape' \
--header 'Accept: application/json' \
--header 'Authorization: Basic TOKEN VALUE' \
--header 'Content-Type: application/json' \
--data '
{
"target": "google_travel_hotels",
"query": "hotels in new york",
"headless": "html",
"parse": true
}
'
const scrape = async() => {
const response = await fetch("https://scraper-api.decodo.com/v2/scrape", {
method: "POST",
body: JSON.stringify({
"target": "google_travel_hotels",
"query": "hotels in new york",
"headless": "html",
"parse": true
}),
headers: {
"Content-Type": "application/json",
"Authorization": "Basic TOKEN VALUE" // 更新为您的授权令牌
},
}).catch(error => console.log(error));
console.log(await response.json())
}
scrape()
import requests
url = "https://scraper-api.decodo.com/v2/scrape"
payload = {
"target": "google_travel_hotels",
"query": "hotels in new york",
"headless": "html",
"parse": True
}
headers = {
"accept": "application/json",
"content-type": "application/json",
"authorization": "Basic TOKEN VALUE" # 更新为您的授权令牌
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)
输出
解析的JSON results 部分中的字段描述如下表所示。请注意,字段数量可能会根据提供的搜索查询而有所不同。
| 结果键 | 描述 |
|---|---|
hotels | 包含酒店详细信息的对象数组。 |
search_information | 与提交的搜索查询相关的信息对象。 |
响应示例
{
"results": [
{
"content": {
"results": {
"hotels": [
{
"name": "The Plaza Hotel",
"rating": 4.5,
"reviews": 1234,
"price": "$500",
"url": "https://www.google.com/travel/hotels/..."
}
],
"search_information": {
"query": "hotels in new york",
"total_results": 500
}
}
}
}
]
}
支持
需要帮助或只是想打个招呼?我们的支持团队全天候为您服务。
您也可以随时通过电子邮件 support@decodo.com 联系我们。
您也可以随时通过电子邮件 support@decodo.com 联系我们。
反馈
找不到您要找的内容?请求一篇文章!
有反馈意见?分享您对我们如何改进的想法。
有反馈意见?分享您对我们如何改进的想法。