0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Pythonで特定のキーワードに関連するキーワードを表示する簡単なプログラム

Posted at

目的

特定のキーワードに関連するキーワードを調べる事が必要になった。

コード

import pytrends
from pytrends.request import TrendReq

def get_related_keywords(keyword):
    pytrends = TrendReq(hl='en-US', tz=360)
    pytrends.build_payload([keyword], cat=0, timeframe='today 5-y', geo='', gprop='')
    related_queries = pytrends.related_queries()
    related_keywords = related_queries[keyword]['top']['query'].tolist()
    return related_keywords

search_keyword = input("キーワードを入力してください: ")
related_keywords = get_related_keywords(search_keyword)

print("関連キーワード:")
for keyword in related_keywords:
    print(keyword)

動作確認

image.png

0
0
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
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?