0
1

はじめに

pytrendsはGoogleトレンドのデータを取得するためのライブラリです。

インストール

pipenvが導入されている前提で進めます。

$ pipenv install pytrends

get started

まずは、動かしてみます。今日本でトレンドになっている検索ワードを取得してみます。

from pytrends.request import TrendReq

pytrends = TrendReq(hl="ja-JP", tz=360)

print(pytrends.trending_searches(pn="japan"))

出力はこのようになります。
console

最近のトレンドを取得できました。

リアルタイムのトレンドを取得する

リアルタイムのトレンドを取得するには、realtime_trending_searchesを使います。

print(pytrends.realtime_trending_searches(pn="JP"))

返却値はpandas.DataFrameです。

スクリーンショット

まとめ

Googleトレンドのデータを取得するためのライブラリpytrendsを使ってみました。
今ある技術を組み合わせることで、トレンドの分析や予測などに使えるかもしれません。

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1