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 details)

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

Details for the file googletrends-0.1.1.tar.gz.

File metadata

  • Download URL: googletrends-0.1.1.tar.gz
  • Upload date:
  • Size: 91.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.1.0.post20200127 requests-toolbelt/0.9.1 tqdm/4.42.0 CPython/3.6.10

File hashes

Hashes for googletrends-0.1.1.tar.gz
Algorithm Hash digest
SHA256 50c94d88d61b8a4b094d0bf0e8243ed8aa5c09a7bb436c62f1af91c63868e95d
MD5 e5576696d489e92d60f3269f03a504ee
BLAKE2b-256 f234e94ded00586573031f25903a9e945a3feb65378cc3f6f5b7ef839dd2245a

See more details on using hashes here.

File details

Details for the file googletrends-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: googletrends-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 92.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.1.0.post20200127 requests-toolbelt/0.9.1 tqdm/4.42.0 CPython/3.6.10

File hashes

Hashes for googletrends-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 526ce957efe01910a6935fe6adef73d5e3a196f6e48d466706c1f9fa71307fc5
MD5 228ed77b63ccf3c525484a3ca52f2cb2
BLAKE2b-256 35be2480481406cf94c96b642ec545f36b8f854f41673ce3d7530463e1aeda45

See more details on using hashes here.

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