Skip to content

Instantly share code, notes, and snippets.

@kengggg
Created December 15, 2022 06:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kengggg/39f35d0870f2be2704544fdc7e9e3831 to your computer and use it in GitHub Desktop.
Save kengggg/39f35d0870f2be2704544fdc7e9e3831 to your computer and use it in GitHub Desktop.
Get the Google Trends data through pytrends
#Pytrends API https://pypi.org/project/pytrends/
#!pip install pytrends
import pandas as pd
import seaborn as sns
from pytrends.request import TrendReq
# create a TrendReq object
pytrends = TrendReq()
# set the keyword for which you want to get search trends
kw_list = ['keyword']
pytrends.build_payload(kw_list, cat=0, timeframe='all', geo='TH', gprop='')
# get search trends data for the keyword
trend_data = pytrends.interest_over_time()
# print the search trends data
print(trend_data)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment