Skip to main content

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 trends
  • False: 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

(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[['title', 'traffic', 'article_url']])

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pylatesttrends-0.1.3.tar.gz (20.5 kB view details)

Uploaded Source

Built Distribution

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

pylatesttrends-0.1.3-py3-none-any.whl (18.9 kB view details)

Uploaded Python 3

File details

Details for the file pylatesttrends-0.1.3.tar.gz.

File metadata

  • Download URL: pylatesttrends-0.1.3.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

Hashes for pylatesttrends-0.1.3.tar.gz
Algorithm Hash digest
SHA256 6053f138c74be0dcf8c5fb2e15762f99d80d35d5b92666b1160f3b870cd024a8
MD5 c366c48286e1ed67a30e91a74fd67bb7
BLAKE2b-256 30b0487fdec47b34cc41766f8d3f0db83ef163cf96439b7956d7c9f588a7a691

See more details on using hashes here.

Provenance

The following attestation bundles were made for pylatesttrends-0.1.3.tar.gz:

Publisher: publish.yml on faraasat/pylatesttrends

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pylatesttrends-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: pylatesttrends-0.1.3-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

Hashes for pylatesttrends-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 90fe2eee1b9768010ca1a97c1b7aefbdc4f0d76c95c55fa91d8ab2bff7265425
MD5 b9399530bd0f1b6c8eec9f884078fd88
BLAKE2b-256 3da5721117ed3da26af46631edc3073e16ec9d4efc96e7d2f72af97a17b24287

See more details on using hashes here.

Provenance

The following attestation bundles were made for pylatesttrends-0.1.3-py3-none-any.whl:

Publisher: publish.yml on faraasat/pylatesttrends

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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