はじめに
Google Trends の非公式APIであるpytrends を使ってみました
https://github.com/GeneralMills/pytrends/blob/master/README.md
install
pip install pytrends
実際に取得してみる
2つのwordに対してトレンドデータを取得してみます
最近(2025年1月末)話題になった中国AIベンチャーDeepSeekとToyotaのトレンドデータを比較します
kw_list[]でワードを、timeframeで期間を指定しています
from pytrends.request import TrendReq
import pandas as pd
import matplotlib as mpl
import matplotlib.pyplot as plt
pytrend = TrendReq()
pytrend.build_payload(kw_list=['DeepSeek', 'Toyota'], timeframe=['2025-01-01 2025-02-01', '2025-01-01 2025-02-01'])
interest_over_time_df = pytrend.interest_over_time()
interest_over_time_df.plot()
plt.show()
実行結果
まとめ
pytrends を使用してトレンドを時系列データとして表示してみました