https://github.com/kaneda2004/pytrendsplus
A Python library to fetch and analyze Google Trends data with additional functionalities such as data visualization, keyword suggestions, and trend predictions
https://github.com/kaneda2004/pytrendsplus
google prediction trends
Last synced: 5 months ago
JSON representation
A Python library to fetch and analyze Google Trends data with additional functionalities such as data visualization, keyword suggestions, and trend predictions
- Host: GitHub
- URL: https://github.com/kaneda2004/pytrendsplus
- Owner: kaneda2004
- Created: 2023-04-06T23:45:20.000Z (about 3 years ago)
- Default Branch: master
- Last Pushed: 2023-04-06T23:54:44.000Z (about 3 years ago)
- Last Synced: 2025-09-23T04:58:13.943Z (9 months ago)
- Topics: google, prediction, trends
- Language: Python
- Homepage:
- Size: 4.88 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# 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:
```python
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:
```commandline
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