Skip to main content

Python package to examine trending, spatio and temporal google searching for input queries.

Project description

googletrends

Python PyPI Version License Downloads Donate

  • googletrends is Python package to examine trending, spatio and temporal google searching for input queries.

Data is al arround us. Some data is easy to get, others are not. Especially when it comes to what people are "thinking" related to an issue/brand/company can be though. However, the "thinking" process can supported by googling about the subject. So if we know what people are searching for, it can give insights in the "common" thoughts. To make it a bit less creepy, lets not do this on an individual basis. I developed the python package googletrends that allows to easily examine the search results per country/region and/or per time-frame and with(out) a specific keyword.

To demonstrate this, lets examine the google searches for the keywords "Corona" and "Wuhan" in the Netherlands and Italy, starting from December 2019 up to today. If you want to examine other keywords, simply pip install the library.

pip install googletrends https://github.com/erdogant/googletrends

Contentsa

Installation

  • Install googletrends from PyPI (recommended). googletrends is compatible with Python 3.6+ and runs on Linux, MacOS X and Windows.
  • A new environment can be created as following:
conda create -n env_googletrends python=3.6
conda activate env_googletrends

Pip install:

pip install googletrends
  • Alternatively, install googletrends from the GitHub source:
git clone https://github.com/erdogant/googletrends.git
cd googletrends
python setup.py install

Import googletrends package

import googletrends as googletrends

Examine google searches over time.

In this example multiple searchwords are examined for multiple countries over time. Countries can be in the form of their abbrevation or country name. The until date is not given and automatically set on today.

# Gather temporal searches
results = googletrends.temporal(['corona','covid-19','virus'], geo=['NL','DE','italy','BE'], date_start='01-01-2020')

# Make plot using default settings
googletrends.plot(results)

Progress looks like this:

# [googletrends] Collecting trends over time for geographically: ['NL', 'DE', 'italy', 'BE']
# [googletrends] 01 January 2020 - 30 March 2020
# [worldmap] Downloading resources..
# [worldmap.extract] Warning: Directory with maps does not exist: .\worldmap\worldmap\data\SVG_MAPS
# [EXTRACT FILES] Directory already exists and will be used: .\worldmap\worldmap\data
# [EXTRACT FILES] Extracting SVG_MAPS.zip..
# 100%|██████████| 1/1 [00:00<00:00,  9.12it/s]
# [EXTRACT FILES] Done!
# [googletrends] [NL] Working on corona..

# [googletrends] [NL] Working on covid-19..
# [googletrends] [DE] Working on corona..
# [googletrends] [DE] Working on covid-19..
# [googletrends] [IT] Working on corona..
# [googletrends] [IT] Working on covid-19..
# [googletrends] [BE] Working on corona..
# [googletrends] [BE] Working on covid-19..

Color and make different subgroups for the results.

googletrends.plot(results, color_by_searchword=False, group_by_searchword=False)

googletrends.plot(results, color_by_searchword=True, group_by_searchword=False)

googletrends.plot(results, color_by_searchword=False, group_by_searchword=True)

googletrends.plot(results, color_by_searchword=True, group_by_searchword=True)

Examine google searches over geographical locations.

In this example multiple searchwords are examined for multiple geographical locations. All frequencies are summarized into one value between the start-stop date. Countries can be in the form of their abbrevation or country name.

# Gather searches over geographical locations
results = googletrends.spatio(['corona','covid-19','virus'], geo=['NL','DE','italy','BE'], date_start='01-01-2020')

# Make plot
googletrends.plot(results)

# Make worldmap plot
googletrends.plot_worldmap(results)

Examine trending searches.

In this example multiple searchwords at multiple geographical locations are examined for trending searches. All frequencies are summarized into one value between the start-stop date.

# Gather searches over geographical locations
results = googletrends.trending(['corona','covid-19','virus'], geo=['NL','DE','italy','BE'], date_start='01-01-2020')

# Make plot
googletrends.plot(results)

Citation

Please cite googletrends in your publications if this is useful for your research. Here is an example BibTeX entry:

@misc{erdogant2020googletrends,
  title={googletrends},
  author={Erdogan Taskesen},
  year={2019},
  howpublished={\url{https://github.com/erdogant/googletrends}},
}

References

Maintainers

Contribute

  • Contributions are welcome.

Licence

See LICENSE for details.

Coffee

  • This work is created and maintained in my free time. If you wish to buy me a Coffee for this work, it is very appreciated.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

googletrends-0.1.1.tar.gz (91.7 kB view hashes)

Uploaded Source

Built Distribution

googletrends-0.1.1-py3-none-any.whl (92.6 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page