Build your Google trends app in Python

Petr Korab
Analytics Vidhya
Published in
3 min readFeb 26, 2021

--

Source: https://blog.dinahosting.com

For companies running their business in e-commerce, it is essential to monitor the customers’ preferences and behavior on the internet. Responsible managers for optimizing companies’ performance online, the SEOs, use a handful of tools for measuring keyword searches on Google. Because lots of data requests commonly repeat, it would be useful to optimize this reporting activity and save time for other interesting projects. This article presents a simple way of preparing a Jupyter notebook that collects data from Google trends and offers it in a Pandas data frame. Finally, I provide a link to the notebook in ready-to-use form.

Google trends API

Pytrends is an unofficial API for Google Trends. It allows accessing Google trends data with a simple interface and automates downloading of reports. The Jupyter notebook will provide the same results as accessing the main Google trends site.

Implementation

The implementation starts with importing necessary libraries and with establishing the Pytrends API connection. Timeout sets the time limit in seconds for accessing Google servers.

--

--

Petr Korab
Analytics Vidhya

Post-doc at Zeppelin University / Python engineer / text mining / data Viz