Skip to main content

A Python library to fetch and analyze Google Trends data with additional functionalities.

Project description

PyTrendsPlus 📈📊

A Python library to fetch and analyze Google Trends data with additional functionalities such as data visualization 📊, keyword suggestions 💡, and trend predictions 🔮.

Installation 🛠️

To install the library, run the following command:

pip install pytrendsplus

Configuration

First, you need to import the library and create an instance of the PyTrendsPlus class:

from pytrendsplus import PyTrendsPlus

trends = PyTrendsPlus()

Usage

Fetch Google Trends Data

To fetch Google Trends data for a list of keywords and a specified time range:

keywords = ['Python', 'JavaScript']
time_range = '2020-01-01 2020-02-01'
data = trends.fetch_data(keywords, time_range)

Data Visualization

To visualize the fetched data as a line chart:

trends.plot_line_chart(data, title='Google Trends Interest Over Time')

Keyword Suggestions

To get keyword suggestions based on a given keyword:

keyword = 'Python'
suggestions = trends.get_suggestions(keyword)
print(suggestions)

Trend Predictions

To predict future trends based on the fetched data:

predictions = trends.predict_trends(data)
print(predictions)

Export data

To export the fetched data to a CSV or JSON file:

file_name = 'data.csv'
trends.export_data(data, file_name)

file_name = 'data.json'
trends.export_data(data, file_name)

Examples

To demonstrate the usage of the pytrendsplus library, you can create a script with the following code:

from pytrendsplus import PyTrendsPlus

# Create an instance of the PyTrendsPlus class
trends = PyTrendsPlus()

# Fetch Google Trends data
keywords = ['Python', 'JavaScript']
time_range = '2020-01-01 2020-02-01'
data = trends.fetch_data(keywords, time_range)

# Visualize the data as a line chart
trends.plot_line_chart(data, title='Google Trends Interest Over Time')

# Get keyword suggestions
keyword = 'Python'
suggestions = trends.get_suggestions(keyword)
print(suggestions)

# Predict future trends
predictions = trends.predict_trends(data)
print(predictions)

# Export the data to a CSV file
file_name = 'data.csv'
trends.export_data(data, file_name)

# Export the data to a JSON file
file_name = 'data.json'
trends.export_data(data, file_name)

Save this script as example.py and run it with the command:

python example.py

License

MIT License

Credits

Shout out to GeneralMills for creating the pytrends library which this library scaffolds off of

https://github.com/GeneralMills/pytrends

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

pytrendsplus-0.1.0.tar.gz (4.7 kB view details)

Uploaded Source

Built Distribution

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

pytrendsplus-0.1.0-py3-none-any.whl (5.4 kB view details)

Uploaded Python 3

File details

Details for the file pytrendsplus-0.1.0.tar.gz.

File metadata

  • Download URL: pytrendsplus-0.1.0.tar.gz
  • Upload date:
  • Size: 4.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.6

File hashes

Hashes for pytrendsplus-0.1.0.tar.gz
Algorithm Hash digest
SHA256 0575de6d03bdfb7bd6910d0dc3ad379a82ebc26e37fdefee5db18b789e0add12
MD5 3b06d2cd6bb9a751eccf83f01f38df2e
BLAKE2b-256 fda91d0684786c4327c97abb0768423b77db3536b125937f8902efab48a44de7

See more details on using hashes here.

File details

Details for the file pytrendsplus-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: pytrendsplus-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 5.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.6

File hashes

Hashes for pytrendsplus-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 24c78b1dfb3eff8f892df8837e082df54ca99bbb8192a825ff0fe5c982287dc7
MD5 a69454d66afff0845b6124d3bc3e3a6f
BLAKE2b-256 033689fdc8e75aeb50f98ecb218945a536b169fc9d20d4fdd3f5daeb469f474c

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