このリポジトリでは、Google Trendsデータを収集するための2つのアプローチを提供します。
- 無料スクレイパー: 小規模プロジェクト、テスト、個人研究、教育目的向けの軽量ソリューションです。
- Bright Data Google Trends Scraper API: エンタープライズレベルで、スケーラブルかつ信頼性の高い大量データ抽出のための堅牢なソリューションです。
小規模なデータ収集プロジェクト向けのシンプルなGoogle Trendsスクレイパーです。
Requirements:
- Python 3.9+
- Playwright(ブラウザ自動化用)
Installation:
pip install playwright
playwright installWebスクレイピングが初めてですか? 当社のPythonでWebスクレイピングを行う初心者ガイドをご覧ください
- google-trends-scraper.py内の以下の変数を編集します。
query = "cryptocurrency" # Your search term
geo = "US" # Country code
hl = "en-US" # Language code- スクリプトを実行します
💡 Pro Tip: Googleのアンチスクレイピングシステムによる検知を抑えるために、HEADLESS = Falseを設定してください。
{
"geoCode": "US-DC",
"geoName": "District of Columbia",
"value": [100],
"formattedValue": ["100"],
"maxValueIndex": 0,
"hasData": [true],
}👉 完全なJSON出力をご覧ください。
無料スクレイパーには制限があります。
- IPアドレスのブロックのリスクが高い
- リクエスト量が限定的
- CAPTCHAが頻繁に発生する
- 大規模スクレイピングには信頼性が低い
信頼性の高い大規模スクレイピングには、より高度なソリューションが必要です。
Bright DataのGoogle Trends APIは、カスタマイズ可能な検索パラメータで構造化されたGoogle Trendsデータを提供します。SERP APIと同じ先進技術を基盤としており、以下を提供します。
- グローバルなロケーション精度: 任意の場所に合わせて結果を調整できます
- Pay-Per-Success Model: 成功したリクエストに対してのみ支払います
- リアルタイムデータ: 最新の検索結果を数秒で取得できます
- スケーラビリティ: ボリューム制限なしで無制限のリクエストに対応します
- コスト効率: インフラと保守コストを削減します
- 最高の信頼性: ブロック回避対策を組み込んだ一貫したパフォーマンスを提供します
- テクニカルサポート: 必要に応じて専門家の支援を利用できます
- Prerequisites:
- Bright Data accountを作成します(新規ユーザーには$5クレジットが付与されます)
- API keyを取得します
- Setup: 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://trends.google.com/trends/explore?q=coffee&geo=GB&brd_trends=timeseries,geo_map&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://trends.google.com/trends/explore?q=coffee&geo=GB&brd_trends=timeseries,geo_map&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を使用してください。geoやbrd_trendsなどの追加パラメータは、以下のAdvanced Featuresセクションで説明しています。
プロキシルーティング方式も使用できます。
cURL Example:
curl -i \
--proxy brd.superproxy.io:33335 \
--proxy-user "brd-customer-<customer-id>-zone-<zone-name>:<zone-password>" \
-k \
"https://trends.google.com/trends/explore?q=coffee&geo=GB&brd_trends=timeseries,geo_map&brd_json=1"
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://trends.google.com/trends/explore?q=coffee&geo=GB&brd_trends=timeseries,geo_map&brd_json=1"
response = requests.get(url, proxies=proxies, verify=False)
with open("serp_native_proxy.json", "w", encoding="utf-8") as file:
file.write(response.text)
print("Response saved to 'serp_native_proxy.json'.")👉 完全なJSON出力をご覧ください。
Note: 本番環境では、当社のSSL Certificate Guideで説明しているとおりにBright DataのSSL証明書を読み込んでください。
Google Trendsは、有意義なインサイトを抽出するためのさまざまなウィジェットを提供します。brd_trendsパラメータを使用して、必要なウィジェットを指定できます。
Available Widgets:
timeseries→ 時系列の関心度geo_map→ 地域別の関心度
Using Multiple Widgets:
複数のウィジェットはカンマ区切りで組み合わせられます。
curl --proxy brd.superproxy.io:33335 \
--proxy-user brd-customer-<customer-id>-zone-<zone-name>:<zone-password> \
-k "https://trends.google.com/trends/explore?q=ChatGPT&geo=US&brd_trends=timeseries,geo_map&brd_json=1"geoパラメータにより、特定の国の検索トレンドデータにフィルタリングできます(例:米国はgeo=US)。省略した場合、APIはデフォルトでグローバルトレンドになります。
Example:
curl --proxy brd.superproxy.io:33335 \
--proxy-user brd-customer-<customer-id>-zone-<zone-name>:<zone-password> \
-k "https://trends.google.com/trends/explore?q=coffee&geo=GB&brd_trends=timeseries,geo_map&brd_json=1"hlパラメータにより、特定の言語で検索トレンドデータを取得できます。
- 言語コード(例:
en-US、fr-FR)を受け付けます - これは返却されるデータの言語に影響し、実際の検索結果には影響しません
Example:
curl --proxy brd.superproxy.io:33335 \
--proxy-user brd-customer-<customer-id>-zone-<zone-name>:<zone-password> \
-k "https://trends.google.com/trends/explore?q=coffee&hl=fr-FR&brd_trends=timeseries,geo_map&brd_json=1"dateパラメータは、トレンドデータを取得するための特定の期間を定義します。
| Value | Time Range |
|---|---|
| now 1-H | 過去1時間 |
| now 4-H | 過去4時間 |
| now 1-d | 過去1日(24時間) |
| now 7-d | 過去7日 |
| today 1-m | 過去30日 |
| today 3-m | 過去90日 |
| today 12-m | 過去12か月(デフォルト) |
| today 5-y | 過去5年 |
| YYYY-MM-DD YYYY-MM-DD | カスタム期間 |
Example for Past 30 Days:
curl --proxy brd.superproxy.io:33335 \
--proxy-user brd-customer-<customer-id>-zone-<zone-name>:<zone-password> \
-k "https://trends.google.com/trends/explore?q=coffee&date=today+1-m&brd_trends=timeseries,geo_map&brd_json=1"Example for Custom Date Range:
curl --proxy brd.superproxy.io:33335 \
--proxy-user brd-customer-<customer-id>-zone-<zone-name>:<zone-password> \
-k "https://trends.google.com/trends/explore?q=coffee&date=2025-01-02+2025-03-03&brd_trends=timeseries,geo_map&brd_json=1"catパラメータにより、特定カテゴリ内の検索トレンドに絞り込めます。
- デフォルトでは、Google Trendsはすべてのカテゴリを横断して検索します
- カテゴリは数値IDで表されます
- カテゴリIDの完全な一覧はGoogle Trendsで確認できます
例 – ビジネス・産業カテゴリ(cat=12)で「Bitcoin」のトレンドを取得します。
curl --proxy brd.superproxy.io:33335 \
--proxy-user brd-customer-<customer-id>-zone-<zone-name>:<zone-password> \
-k "https://trends.google.com/trends/explore?q=bitcoin&cat=12&brd_trends=timeseries,geo_map&brd_json=1"gprop(Google Property)パラメータは、特定のGoogleサービス別に検索トレンドをフィルタリングします。
| Value | Google Property |
|---|---|
| images | Google Images |
| news | Google News |
| froogle | Google Shopping |
| youtube | YouTube Search |
省略した場合、デフォルトはウェブ検索になります。
Examples:
- 画像検索トレンド(gprop=images):
curl --proxy brd.superproxy.io:33335 \
--proxy-user brd-customer-<customer-id>-zone-<zone-name>:<zone-password> \
-k "https://trends.google.com/trends/explore?q=nft+art&gprop=images&brd_trends=timeseries,geo_map&brd_json=1"- ニュース検索トレンド(gprop=news):
curl --proxy brd.superproxy.io:33335 \
--proxy-user brd-customer-<customer-id>-zone-<zone-name>:<zone-password> \
-k "https://trends.google.com/trends/explore?q=AI+advancements&gprop=news&brd_trends=timeseries,geo_map&brd_json=1"
- YouTube検索トレンド(gprop=youtube):
curl --proxy brd.superproxy.io:33335 \
--proxy-user brd-customer-<customer-id>-zone-<zone-name>:<zone-password> \
-k "https://trends.google.com/trends/explore?q=python+tutorials&gprop=youtube&brd_trends=timeseries,geo_map&brd_json=1"
- Documentation: SERP API Docs
- SEO Use Cases: SEO Tracking and Insights
- Additional Guides:
- Technical Articles:
- Technical Support: Contact Us



