⚠️ 2025年1月時点で、検索結果をレンダリングするためにGoogleはJavaScriptを必須としています。この更新は、JavaScript非対応の手法に依存する従来型のボット、スクレイパー、SEOツールをブロックすることを目的としています。その結果、市場調査やランキング分析のためにGoogle Searchを利用する企業は、JavaScriptレンダリングに対応したツールを採用する必要があります。
このリポジトリでは、Google SERPデータを収集するための2つのアプローチを提供しています。
- 基本的なデータ収集に適した、無料の小規模スクレイパー
- 大量かつ堅牢なデータニーズ向けに構築された、エンタープライズグレードのAPIソリューション
基本的なデータ収集ニーズ向けの、軽量なGoogleスクレイパーです。
- File: Googleでクエリする検索語のリスト(必須)
- Pages: データをスクレイピングするGoogleページ数
これらのパラメータを、Python fileで変更してください。
HEADLESS = False
MAX_RETRIES = 2
REQUEST_DELAY = (1, 4)
SEARCH_TERMS = [
"nike shoes",
"macbook pro"
]
PAGES_PER_TERM = 3 💡 Tip: HEADLESS = False に設定すると、Googleの検知メカニズムを回避しやすくなります。
Googleは、複数のアンチスクレイピング対策を実装しています。
- CAPTCHAs: 人間とボットを区別するために使用されます
- IP Blocks: 不審なアクティビティに対する一時的または恒久的なBANです
- Rate Limiting: 急速なリクエストはブロックを引き起こす可能性があります
- Geotargeting: 結果は場所、言語、デバイスによって変化します
- Honeypot Traps: 自動アクセスを検出するための隠し要素です
複数回リクエストすると、おそらくGoogleのCAPTCHAチャレンジに遭遇します。
Bright Data's Google Search API は、カスタマイズ可能な検索パラメータを使用して、Googleから実ユーザーの検索結果を提供します。SERP APIと同じ先進技術に基づいて構築されており、公開データを大規模にスクレイピングする際に、高い成功率と堅牢なパフォーマンスを提供します。
- 大量でも高い成功率
- 成功したリクエストに対してのみ課金
- 高速なレスポンスタイム(5秒未満)
- ジオロケーションターゲティング – 任意の国・都市・デバイスからデータを抽出
- 出力形式 – JSONまたは生HTMLでデータを取得
- 複数の検索タイプ – News、images、shopping、jobsなど
- 非同期リクエスト – 結果をバッチで取得
- スケール向けに設計 – 高トラフィックとピーク負荷に対応
📌 SERP Playgroundで無料でお試しください。
- Prerequisites:
- Bright Data accountを作成してください(新規ユーザーには$5クレジットが付与されます)
- API keyを取得してください
- Setup: step-by-step guideに従って、Bright DataアカウントにSERP APIを統合してください
- Implementation Methods:
- Direct API Access
- Native Proxy-Based 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/search?q=ollama&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/search?q=ollama&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'.")👉 full JSON outputをご覧ください。
Note: パース済みJSONには
brd_json=1を使用し、パース済みJSON + 完全にネストされたHTMLにはbrd_json=htmlを使用してください。
検索結果のパースについて詳しくは、SERP API Parsing Guideをご覧ください。
代わりに、プロキシルーティング方式を使用することもできます。
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/search?q=ollama"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/search?q=ollama"
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'.")👉 full HTML outputをご覧ください。
本番環境では、Bright DataのSSL証明書を読み込んでください(SSL Certificate Guideを参照してください)。
-
gl(Country Code)- 検索結果の国を決定する2文字の国コードです
- 特定の国から行われた検索をシミュレートします
Example: フランスでレストランを検索する
curl --proxy brd.superproxy.io:33335 \ --proxy-user "brd-customer-<customer-id>-zone-<zone-name>:<zone-password>" \ "https://www.google.com/search?q=best+restaurants+in+paris&gl=fr"
-
hl(Language Code)- ページコンテンツの言語を設定する2文字の言語コードです
- インターフェースおよび検索結果の言語に影響します
Example: 日本で寿司店を検索する(結果は日本語)
curl --proxy brd.superproxy.io:33335 \ --proxy-user "brd-customer-<customer-id>-zone-<zone-name>:<zone-password>" \ "https://www.google.com/search?q=best+sushi+restaurants+in+tokyo&hl=ja"
より適切なローカライズのために、両方のパラメータを併用できます。
curl --proxy brd.superproxy.io:33335 \ --proxy-user "brd-customer-<customer-id>-zone-<zone-name>:<zone-password>" \ "https://www.google.com/search?q=best+hotels+in+berlin&gl=de&hl=de"
-
tbm(Search Category)- 特定の検索タイプ(画像、ニュースなど)を指定します
- Options:
tbm=isch→ Imagestbm=shop→ Shoppingtbm=nws→ Newstbm=vid→ Videos
Example(Shopping検索):
curl --proxy brd.superproxy.io:33335 \ --proxy-user "brd-customer-<customer-id>-zone-<zone-name>:<zone-password>" \ "https://www.google.com/search?q=macbook+pro&tbm=shop" -
ibp(Jobs Search Parameter)- 求人関連の検索に特化して使用します
- 例:
ibp=htl;jobsは求人リストを返します
Example:
curl --proxy brd.superproxy.io:33335 \ --proxy-user "brd-customer-<customer-id>-zone-<zone-name>:<zone-password>" \ "https://www.google.com/search?q=technical+copywriter&ibp=htl;jobs"
結果ページ間を移動したり、表示される結果数を調整したりします。
-
start- 検索結果の開始位置を定義します
- Examples:
start=0(default)- 1ページ目start=10- 2ページ目(結果11-20)start=20- 3ページ目(結果21-30)
Example(11番目の結果から開始):
curl --proxy brd.superproxy.io:33335 \ --proxy-user "brd-customer-<customer-id>-zone-<zone-name>:<zone-password>" \ "https://www.google.com/search?q=best+coding+laptops+2025&start=10" -
num- 1ページあたりに返す結果数を定義します
- Examples:
num=10(default)- 10件の結果を返しますnum=50- 50件の結果を返します
Example(40件の結果を返す):
curl --proxy brd.superproxy.io:33335 \ --proxy-user "brd-customer-<customer-id>-zone-<zone-name>:<zone-password>" \ "https://www.google.com/search?q=best+coding+laptops+2025&num=40"
uule パラメータは、特定の場所に基づいて検索結果をカスタマイズします。
- プレーンテキストではなく、エンコードされた文字列が必要です。
- Google's geotargeting CSVのCanonical Name列で、生のロケーション文字列を見つけてください。
- サードパーティのコンバーターまたは組み込みライブラリを使用して、生の文字列をエンコード形式に変換してください。
- APIリクエストで、
uuleの値としてエンコード文字列を含めてください。
curl --proxy brd.superproxy.io:33335 \
--proxy-user "brd-customer-<customer-id>-zone-<zone-name>:<zone-password>" \
"https://www.google.com/search?q=best+hotels+in+paris&uule=w+CAIQICIGUGFyaXM"brd_mobile パラメータを使用して、特定デバイスからのリクエストをシミュレートします。
| Value | Device | User-Agent Type |
|---|---|---|
0 or omit |
Desktop | Desktop |
1 |
Mobile | Mobile |
ios or iphone |
iPhone | iOS |
ipad or ios_tablet |
iPad | iOS Tablet |
android |
Android | Android |
android_tablet |
Android Tablet | Android Tablet |
Example: Mobile Search
curl --proxy brd.superproxy.io:33335 \
--proxy-user "brd-customer-<customer-id>-zone-<zone-name>:<zone-password>" \
"https://www.google.com/search?q=best+laptops&brd_mobile=1"brd_browser パラメータを使用して、特定ブラウザからのリクエストをシミュレートします。
brd_browser=chrome— Google Chromebrd_browser=safari— Safaribrd_browser=firefox— Mozilla Firefox(brd_mobile=1と互換性がありません)
指定しない場合、APIはランダムなブラウザを使用します。
Example:
curl --proxy brd.superproxy.io:33335 \
--proxy-user "brd-customer-<customer-id>-zone-<zone-name>:<zone-password>" \
"https://www.google.com/search?q=best+gaming+laptops&brd_browser=chrome"Example(ブラウザとデバイスタイプの組み合わせ):
curl --proxy brd.superproxy.io:33335 \
--proxy-user "brd-customer-<customer-id>-zone-<zone-name>:<zone-password>" \
"https://www.google.com/search?q=best+smartphones&brd_browser=safari&brd_mobile=ios"brd_json パラメータを使用して、検索結果を構造化形式で受け取ります。
- Options:
brd_json=1- パース済みJSON形式で結果を返しますbrd_json=html- 生HTMLを含む追加の"html"フィールドを持つJSONを返します
Example(JSON output):
curl --proxy brd.superproxy.io:33335 \
--proxy-user "brd-customer-<customer-id>-zone-<zone-name>:<zone-password>" \
"https://www.google.com/search?q=best+hotels+in+new+york&brd_json=1"Example(生HTML付きJSON):
curl --proxy brd.superproxy.io:33335 \
--proxy-user "brd-customer-<customer-id>-zone-<zone-name>:<zone-password>" \
"https://www.google.com/search?q=top+restaurants+in+paris&brd_json=html"詳細は SERP API Parsing Guideをご覧ください。
以下のパラメータでホテル検索を絞り込めます。
-
hotel_occupancy(Number of Guests)- 宿泊人数を設定します(最大4)
- Examples:
hotel_occupancy=1→ 1名hotel_occupancy=2→ 2名(default)hotel_occupancy=4→ 4名
Example(ニューヨークのホテルを4名で検索):
curl --proxy brd.superproxy.io:33335 \ --proxy-user "brd-customer-<customer-id>-zone-<zone-name>:<zone-password>" \ "https://www.google.com/search?q=hotels+in+new+york&hotel_occupancy=4" -
hotel_dates(Check-in & Check-out Dates)- 特定の日付範囲で結果をフィルタリングします
- Format: YYYY-MM-DD, YYYY-MM-DD
Example(2025年5月1日から5月3日までのパリのホテルを検索):
curl --proxy brd.superproxy.io:33335 \ --proxy-user "brd-customer-<customer-id>-zone-<zone-name>:<zone-password>" \ "https://www.google.com/search?q=hotels+in+paris&hotel_dates=2025-05-01%2C2025-05-03"Combined Example:
curl --proxy brd.superproxy.io:33335 \ --proxy-user "brd-customer-<customer-id>-zone-<zone-name>:<zone-password>" \ "https://www.google.com/search?q=hotels+in+tokyo&hotel_occupancy=2&hotel_dates=2025-05-01%2C2025-05-03"
同一のpeerおよびセッション内で、複数の検索リクエストを同時に送信します。結果の比較に最適です。
- 検索バリエーションを含む
multi配列でPOSTリクエストを送信します - 後で結果を取得するための
response_idを取得します - 処理完了後、
response_idを使用して結果を取得します
Step 1: Send Parallel Requests
RESPONSE_ID=$(curl -i --silent --compressed \
"https://api.brightdata.com/serp/req?customer=<customer-id>&zone=<zone-name>" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer API_TOKEN" \
-d $'{
"country": "us",
"multi": [
{"query": {"q": "top+macbook+for+developers", "num": 20}},
{"query": {"q": "top+macbook+for+developers", "num": 100}}
]
}' | sed -En 's/^x-response-id: (.*)/\1/p' | tr -d '\r')
echo "Response ID: $RESPONSE_ID"Step 2: Fetch Results
curl -v --compressed \
"https://api.brightdata.com/serp/get_result?customer=<customer-id>&zone=<zone-name>&response_id=${RESPONSE_ID}" \
-H "Authorization: Bearer API_TOKEN"1つのリクエストで複数のキーワードを検索することもできます。
{
"multi":[
{"query":{"q":"best+smartphones+2025"}},
{"query":{"q":"best+laptops+2025"}}
]
}非同期リクエストについて詳しくはこちらをご覧ください。
Googleは、検索結果の上部にAI生成の要約(AI Overviews)を含めることがあります。brd_ai_mode=1 を使用すると、これらのAI生成オーバービューが表示される可能性が高まります。
curl --proxy brd.superproxy.io:33335 \
--proxy-user "brd-customer-<customer-id>-zone-<zone-name>:<zone-password>" \
"https://www.google.com/search?q=how+does+caffeine+affect+sleep&brd_ai_mode=1"- Documentation: SERP API Docs
- SEO Use Cases: SEO Tracking and Insights
- Other Guides:
- Interesting Reads:
- Technical Support: Contact Us











