Get the latest trends from Google Trends
Project description
PyLatestTrends
PyLatestTrends is a Python library that allows you to fetch and analyze trending topics from Google Trends. Whether you're building a data analytics dashboard, content pipeline, or market intelligence tool, this package provides a simple interface to extract trending keywords by country, category, time period, and relevance.
🚀 Features
- 📈 Scrape trends going on in countries from Google Trends in real time.
- 🌍 Filter by country (using ISO codes) for localized trends.
- 🕒 Customize time ranges like last 4 hours, 24 hours, or 7 days.
- 🗂 Sort by volume, recency, or relevance.
- 🧠 Filter by specific categories (e.g., Technology, Business, Health).
- 🐍 Built for data science — returns results in a Pandas DataFrame.
- 🔍 Optional logging for debugging or verbose insights.
📦 Installation
pip install pylatesttrends
🧑💻 Quick Start
You can start by plucking in only this code and you will be able to get the trends.
from pylatesttrends import generate_payload, get_trends
# Create payload for the US
payload = generate_payload("US")
# Fetch trending data
result = get_trends(payload)
# View DataFrame
print(result.head())
⚙️ Parameters & Customization
You can customize the generate_payload() function with the following options:
geo (Required)
The ISO 3166-1 alpha-2 country code to fetch trends from.
payload = generate_payload("US")
Full list of supported ISO codes (e.g., US, IN, GB, DE, JP) is provided below.
start_trending
Filter trends based on time when they started trending.
payload = generate_payload("US", start_trending="48h")
Valid time options:
4h, 24h, 48h, 7d
category
Choose a trend category to narrow the results.
payload = generate_payload("US", category="Technology")
Available categories:
Autos and Vehicles, Beauty and Fashion, Business and Finance, Climate, Entertainment, Food and Drink,
Games, Health, Hobbies and Leisure, Jobs and Education, Law and Government, Other, Pets and Animals,
Politics, Science, Shopping, Sports, Technology, Travel and Transportation
trend_status_active_trends
Include or exclude active trending status.
payload = generate_payload("US", trend_status_active_trends=True)
True: show only currently active trendsFalse: include historical or past-trending keywords
sort_by
Sort the results using various attributes:
payload = generate_payload("US", sort_by="recency")
Valid values:
title, search-volume, recency, relevance
base_url (Advanced)
Set a custom base URL for data scraping (for proxies or mirrors).
Set a custom base URL for data scraping (for proxies or mirrors).
Logging Option
Enable logging for insight into data retrieval:
result = get_trends(payload, "print") # or use "logging"
Output Format
The result returned from get_trends() is a pandas DataFrame containing:
- Trends: trend name
- Search volume: volume of the search
- Started: trend start time
- Ended: trend end time
- Trend breakdown: searches
- Explore link: trend explore link
Use Cases
Content Strategy: Discover trending topics in your region for blogs, YouTube, or news content. Market Research: Analyze shifts in consumer interest over time. Social Media: Track viral search terms to time your posts effectively. SEO Planning: Create keyword-rich content based on real-time demand.
Requirements
- Python 3.9+
- Selenium
- Pandas
- Webdriver Manager
(Dependencies are installed automatically with pip.)
Example: Get Trending Tech Topics in United States Over Last 24 Hours
payload = generate_payload("US", category="Technology", start_trending="24h")
df = get_trends(payload, "logging")
print(df[['Trends', 'Search volume', 'Explore link']])
Links
Contributing
Contributions are welcome! Open issues, fork the repo, and submit pull requests.
License
This project is licensed under the GNU General Public License v3 (GPLv3) License.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pylatesttrends-0.1.6.tar.gz.
File metadata
- Download URL: pylatesttrends-0.1.6.tar.gz
- Upload date:
- Size: 20.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8505750ef0f049315c95abea399c4189c1c491528c39bfe13a1a04c235739cb8
|
|
| MD5 |
761a4f266c3f11a990092b3c196761d7
|
|
| BLAKE2b-256 |
f7970ba891c158e9b9b4227da6054ccaae9422da37b6cb9ad27d39993fa73597
|
Provenance
The following attestation bundles were made for pylatesttrends-0.1.6.tar.gz:
Publisher:
publish.yml on faraasat/pylatesttrends
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pylatesttrends-0.1.6.tar.gz -
Subject digest:
8505750ef0f049315c95abea399c4189c1c491528c39bfe13a1a04c235739cb8 - Sigstore transparency entry: 208397313
- Sigstore integration time:
-
Permalink:
faraasat/pylatesttrends@1f90c408649a27043cfbc030493d317d195cf2a0 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/faraasat
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@1f90c408649a27043cfbc030493d317d195cf2a0 -
Trigger Event:
push
-
Statement type:
File details
Details for the file pylatesttrends-0.1.6-py3-none-any.whl.
File metadata
- Download URL: pylatesttrends-0.1.6-py3-none-any.whl
- Upload date:
- Size: 18.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
caf347f19886dffc827e9d72b5071228bccb63050b0c59bfc61b079cad68b040
|
|
| MD5 |
91c5c6247159d05872d5b9b58a79cdc2
|
|
| BLAKE2b-256 |
4c61e1e4cf061a1ed2dfd77dd4ca4ee37a5a336507de5c8efe758e0e4ed2fbbc
|
Provenance
The following attestation bundles were made for pylatesttrends-0.1.6-py3-none-any.whl:
Publisher:
publish.yml on faraasat/pylatesttrends
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pylatesttrends-0.1.6-py3-none-any.whl -
Subject digest:
caf347f19886dffc827e9d72b5071228bccb63050b0c59bfc61b079cad68b040 - Sigstore transparency entry: 208397314
- Sigstore integration time:
-
Permalink:
faraasat/pylatesttrends@1f90c408649a27043cfbc030493d317d195cf2a0 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/faraasat
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@1f90c408649a27043cfbc030493d317d195cf2a0 -
Trigger Event:
push
-
Statement type: