Skip to content

無料のスクレイパーまたは Bright Data の Google Hotels API を使用して、Google からリアルタイムのホテルデータをスクレイピングし、大規模かつ信頼性の高いデータ収集を実現します。

Notifications You must be signed in to change notification settings

bright-jp/google-hotels-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Google Hotels Scraper

Promo

Googleは最大級の旅行データアグリゲーターの1つです。本ドキュメントでは、Googleからリアルタイムのホテルデータをスクレイピングする方法を2つご紹介します。

  1. 無料スクレイパー:小規模なニーズに最適です。
  2. Bright Data Google Hotels API:単一のAPIコールで公開されているGoogle Hotelsデータを大規模に収集できるエンタープライズ向けソリューションです(SERP Scraping APIの一部です)。

Table of Contents

Free Scraper

小規模にGoogle Hotelsデータを抽出するための、素早く簡単なスクレイパーです。

free-google-hotels-scraper

Setup

要件:

インストール:

pip install pandas tqdm selenium beautifulsoup4 webdriver-manager

Note: Webスクレイピングが初めての場合は、初心者向けPython Webスクレイピングチュートリアル または Seleniumを使ったWebスクレイピングガイド から始めることをおすすめします。

Usage

必要なパラメータを指定して、google-hotels-scraper.py スクリプトを実行します。

python3 google-hotels-scraper.py --location "Dubai" --max_hotels 200

Parameters:

  • location – ホテルデータの対象ロケーション
  • max_hotels – スクレイピングするホテル数

💡 Pro Tip: Googleのアンチスクレイピングシステムによる検知を抑えるために、スクリプト内の options.add_argument("--headless=new") の行をコメントアウトしてください。

Sample Output

google-hotels-scraper-csv-output

Limitations

無料スクレイパーにはいくつかの制約があります。

  • IPブロックの高いリスク
  • リクエスト量の制限
  • CAPTCHAの頻発
  • 大規模スクレイピングには不向き(信頼性が低い)

より大規模で信頼性の高いデータ収集には、以下のBright Dataの専用ソリューションをご検討ください 👇

Bright Data Google Hotels API

Bright DataのGoogle Hotels APISERP Scraping API の一部であり、当社の高度な プロキシネットワーク を使用します。CAPTCHAやIPブロックを心配することなく、公開されているGoogle Hotelsデータを大規模に収集できます。

Key Features

  • グローバルなロケーション精度:結果を特定のロケーションに合わせて調整できます
  • Pay-Per-Successモデル:成功したリクエストに対してのみ課金されます
  • リアルタイムデータ:最新のホテル情報を数秒で取得できます
  • スケーラビリティ:ボリューム制限なしで無制限のリクエストを処理できます
  • コスト効率:インフラおよびメンテナンスコストを削減できます
  • 高い信頼性:内蔵のブロック回避対策により一貫したパフォーマンスを提供します
  • 24/7サポート:必要なときにいつでも専門家がサポートします

Prerequisites

  1. Bright Dataアカウント を作成します(新規ユーザーは$5のクレジットが付与されます)
  2. API key を生成します
  3. ステップバイステップガイド に従ってSERP APIとアクセス認証情報を設定します
  4. Google Hotels APIを使用するには、クエリしたいホテルのentity IDが必要です。これは次の手順で確認できます。
    1. Googleでホテル名を検索します
    2. 右クリックして「ページのソースを表示」を選択します
    3. ページ内で「/entity」を検索し、entity IDを見つけます

Direct API Access

APIエンドポイントに直接リクエストします。

cURL Example:

curl https://api.brightdata.com/request \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer API_TOKEN" \
  -d '{
        "zone": "ZONE_NAME",
        "url": "https://www.google.com/travel/hotels/entity/CgoIyNaqqL33x5ovEAE/prices?brd_json=1",
        "format": "raw"
      }'

Python Example:

import requests
import json

url = "https://api.brightdata.com/request"
headers = {"Content-Type": "application/json", "Authorization": "Bearer API_TOKEN"}

payload = {
    "zone": "ZONE_NAME",
    "url": "https://www.google.com/travel/hotels/entity/CgoIyNaqqL33x5ovEAE/prices?brd_json=1",
    "format": "raw",
}

response = requests.post(url, headers=headers, json=payload)

with open("serp-direct-api.json", "w") as file:
    json.dump(response.json(), file, indent=4)

print("Response saved to 'serp-direct-api.json'.")

👉 完全なJSON出力 をご覧ください。

Note: 解析済みJSONには brd_json=1 を、解析済みJSON + 完全なネストHTMLには brd_json=html を使用してください。

Native Proxy-Based Access

Bright Dataのプロキシルーティング方式も使用できます。

cURL Example:

curl -i \
  --proxy brd.superproxy.io:33335 \
  --proxy-user "brd-customer-<customer-id>-zone-<zone-name>:<zone-password>" \
  -k \
  "https://www.google.com/travel/hotels/entity/CgoIyNaqqL33x5ovEAE/prices?brd_json=html"

Python Example:

import requests
import urllib3

urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)

host = "brd.superproxy.io"
port = 33335
username = "brd-customer-<customer-id>-zone-<zone-name>"
password = "<zone-password>"
proxy_url = f"http://{username}:{password}@{host}:{port}"

proxies = {"http": proxy_url, "https": proxy_url}
url = "https://www.google.com/travel/hotels/entity/CgoIyNaqqL33x5ovEAE/prices?brd_json=html"
response = requests.get(url, proxies=proxies, verify=False)

with open("serp-native-proxy.html", "w", encoding="utf-8") as file:
    file.write(response.text)

print("Response saved to 'serp-native-proxy.html'.")

👉 完全なJSON出力 をご覧ください。

Note: 本番環境では、SSL Certificate Guide に記載のとおり、Bright DataのSSL証明書を読み込んでください。

Advanced Features

Bright DataのAPIは、Google Hotelsデータ抽出を微調整するための多くの高度なパラメータをサポートしています。以下は Native Proxy-Based Access を使用した例ですが、Direct API Accessでも適用できます。

Localization Parameters

bright-data-google-hotels-scraper-api-localization

これらのパラメータは、検索の国と言語を定義します。

Parameter Description Example
gl 2文字の国コード gl=us (United States)
hl 2文字の言語コード hl=en (English)

Example: アメリカ合衆国でホテルを検索し、結果を英語で表示します。

curl --proxy brd.superproxy.io:33335 --proxy-user brd-customer-<customer-id>-zone-<zone-name>:<zone-password> \
"https://www.google.com/travel/hotels/entity/CgoI4NzJmsPmkpU6EAE/prices?gl=us&hl=en"

Booking Parameters

bright-data-google-hotels-scraper-api-booking-params

これらのパラメータは、日付、宿泊者数、無料キャンセル、宿泊タイプに基づいて結果を絞り込むのに役立ちます。

Parameter Description Format Example
brd_dates チェックイン日およびチェックアウト日 YYYY-MM-DD,YYYY-MM-DD brd_dates=2025-08-15,2025-08-20
brd_occupancy 宿泊者数(大人 + 子ども) <adults>,<child1_age>,<child2_age> brd_occupancy=3,6,9 (大人3名、子ども2名(6歳・9歳))
brd_free_cancellation 返金可能な予約のみ表示します true or false brd_free_cancellation=true
brd_accomodation_type 滞在タイプ hotels or vacation_rentals brd_accomodation_type=vacation_rentals
brd_currency 価格表示の通貨 3文字の通貨コード brd_currency=GBP (British Pounds)

Example: 特定のパラメータを指定してホテル滞在を検索します。

curl --proxy brd.superproxy.io:33335 \
  --proxy-user brd-customer-<customer-id>-zone-<zone-name>:<zone-password> \
  "https://www.google.com/travel/hotels/entity/CgoIyNaqqL33x5ovEAE/prices\
?brd_dates=2025-04-15,2025-04-20\
&brd_occupancy=3,6,9\
&brd_free_cancellation=true\
&brd_currency=GBP"

Device Type Parameters

デフォルトでは、リクエストはデスクトップのuser-agentを模倣しますが、モバイルに変更できます。

Parameter Description
brd_mobile=0 ランダムなデスクトップuser-agent(デフォルト)
brd_mobile=1 ランダムなモバイルuser-agent
brd_mobile=ios iPhone user-agent
brd_mobile=android Android phone user-agent
brd_mobile=ipad iPad user-agent
brd_mobile=android_tablet Android tablet user-agent

Example: Android phone user-agentでホテルデータを取得します。

curl --proxy brd.superproxy.io:33335 --proxy-user brd-customer-<customer-id>-zone-<zone-name>:<zone-password> \
"https://www.google.com/travel/hotels/entity/CgoIyNaqqL33x5ovEAE/prices?brd_mobile=android"

Response Format

デフォルトではレスポンスはHTMLですが、JSONレスポンスを要求できます。

Parameter Description
brd_json=1 HTMLの代わりにJSONレスポンスを返します
brd_json=html JSON + 完全なネストHTML

Example: JSON形式でホテルの価格データを取得します。

curl --proxy brd.superproxy.io:33335 --proxy-user brd-customer-<customer-id>-zone-<zone-name>:<zone-password> \
"https://www.google.com/travel/hotels/entity/CgoIyNaqqL33x5ovEAE/prices?brd_json=1"

Alternative Solutions

Web Scraper APIs に加えて、Bright Dataは旅行業界のニーズに合わせた、すぐに使える データセット も提供しています。

Support & Resources

About

無料のスクレイパーまたは Bright Data の Google Hotels API を使用して、Google からリアルタイムのホテルデータをスクレイピングし、大規模かつ信頼性の高いデータ収集を実現します。

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published