Skip to main content

This Python script fetches Google Trends data for specific keywords over the past 7 days in Japan and plots the relative interest over time, handling rate limits by pausing for 60 seconds if necessary.

Project description

Google Trends Plotter

This Python script uses the pytrends library to fetch and plot Google Trends data for given keywords.

Dependencies

  • sys
  • time
  • pytrends
  • japanize_matplotlib
  • matplotlib

How it works

The script takes command line arguments as search queries. It fetches the Google Trends data for these queries over the past 7 days in Japan, and plots the data using matplotlib.

The plot_trends function initializes a TrendReq object with Japanese language and timezone settings. It then builds a payload with the given keywords, category set to 0 (all categories), timeframe set to 'now 7-d' (past 7 days), and geo set to 'JP' (Japan).

The function then fetches the interest over time data for these keywords and plots the data for each keyword. The plot is saved as 'result.png'. Please note that the y-axis of the plot represents relative values (values relative to the maximum value, which is set to 100).

If the number of requests is too high, the script waits for 60 seconds before making the next request.

Usage

Run the script with the search queries as command line arguments. For example:

python jtrends.py コロナウイルス COVID-19

result

If no command line arguments are provided, the script will prompt you to provide at least one search query.

Note

Please be aware of Google’s rate limits when using this script.

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

jtrends-0.0.2.tar.gz (2.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

jtrends-0.0.2-py3-none-any.whl (3.0 kB view details)

Uploaded Python 3

File details

Details for the file jtrends-0.0.2.tar.gz.

File metadata

  • Download URL: jtrends-0.0.2.tar.gz
  • Upload date:
  • Size: 2.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.13

File hashes

Hashes for jtrends-0.0.2.tar.gz
Algorithm Hash digest
SHA256 ab0c9febcf0c53a3f1342f2fc0983c4869aac4b0ef2a662890641c74611eea3c
MD5 5cb11668fdc301af85448d0619307e57
BLAKE2b-256 3c2bdf177f672dd2712b8e6df423e6e05cff2064e5b738568591f8aaffd1c5c8

See more details on using hashes here.

File details

Details for the file jtrends-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: jtrends-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 3.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.13

File hashes

Hashes for jtrends-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 98a898019850c141e7b7fddbbe419b86248592f6d0e654318844f5134c0bfc89
MD5 47aeddcf9f2b353e78d301729490ed94
BLAKE2b-256 d68ac7d7437f22279a710a0cbb150ad7e3fbe82bbda7612aade7143ef7f9a493

See more details on using hashes here.

Supported by

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