Skip to content

Commit

Permalink
pytrends: creation
Browse files Browse the repository at this point in the history
  • Loading branch information
David Arroyo Menéndez committed Nov 24, 2018
1 parent e30f6ba commit 8b6cec0
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions pytrends/pytrends-example.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
from pytrends.request import TrendReq


# Login to Google. Only need to run this once, the rest of requests will use the same session.
pytrend = TrendReq()

# Create payload and capture API tokens. Only needed for interest_over_time(), interest_by_region() & related_queries()
pytrend.build_payload(kw_list=['pizza', 'bagel'])

# Interest Over Time
interest_over_time_df = pytrend.interest_over_time()
print(interest_over_time_df.head())

# Interest by Region
interest_by_region_df = pytrend.interest_by_region()
print(interest_by_region_df.head())

# Related Queries, returns a dictionary of dataframes
related_queries_dict = pytrend.related_queries()
print(related_queries_dict)

# Get Google Hot Trends data
# trending_searches_df = pytrend.trending_searches()
# print(trending_searches_df.head())

# # Get Google Top Charts
# top_charts_df = pytrend.top_charts(cid='actors', date=201611)
# print(top_charts_df.head())

# # # Get Google Keyword Suggestions
# suggestions_dict = pytrend.suggestions(keyword='pizza')
# print(suggestions_dict)

0 comments on commit 8b6cec0

Please sign in to comment.