Skip to content

Latest commit

 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 

Repository files navigation

Google Trends Scraper

google-trends-scraper

pypi python npm node license

A Google Trends scraper reads what people are searching for right now and returns it as data. This repository covers how to scrape Google Trends reliably, which surfaces actually return structured output, and what each call costs.

Every command and figure here was run against the live API on 2026-08-25.

Contents

Google needs its own parameter

Google properties are not treated like ordinary pages. Send a trends.google.com URL through the HTML API and the request is rejected before it goes anywhere:

{"errors": {"query": {"custom_google": ["If you wish to scrape Google, use the custom_google=True parameter!"]}}}

Adding custom_google=true is what makes the call legal, and it is also why a Google request is priced differently from a normal page.

Scrape Google Trends

curl -G "https://app.scrapingbee.com/api/v1" \
     -H "Authorization: Bearer YOUR-API-KEY" \
     --data-urlencode "url=https://trends.google.com/trending/rss?geo=US" \
     --data-urlencode "custom_google=true" \
     --data-urlencode "render_js=false"

The feed is XML, ten entries per country, refreshed continuously.

In Python, parsing it is standard library work. No extra dependency needed:

import requests, xml.etree.ElementTree as ET

HT = "{https://trends.google.com/trending/rss}"

response = requests.get(
    "https://app.scrapingbee.com/api/v1",
    headers={"Authorization": "Bearer YOUR-API-KEY"},
    params={"url": "https://trends.google.com/trending/rss?geo=US",
            "custom_google": "true", "render_js": "false"},
    timeout=180,
)
print("credits:", response.headers["Spb-cost"])

for item in ET.fromstring(response.text).iter("item"):
    title = item.findtext("title")
    traffic = item.findtext(f"{HT}approx_traffic")
    stories = item.findall(f"{HT}news_item")
    print(traffic, title, f"({len(stories)} stories)")

The response

Each entry carries the query, a traffic bucket, a timestamp, a representative image, and up to three attached news stories:

1000+  measles              (3 stories)
1000+  daniel diemer        (3 stories)
500+   military aircraft    (3 stories)
200+   oil                  (3 stories)

The ht:news_item children hold ht:news_item_title, ht:news_item_url, ht:news_item_source and ht:news_item_picture, which is usually enough to judge whether a spike is relevant without a second request.

Reading traffic buckets correctly

approx_traffic is a floor, not a count. Google publishes "500+", meaning at least five hundred, and never a precise figure. Two consequences worth designing around:

  1. Parse the digits if you want to sort or threshold, but keep the original string for display.
  2. Do not chart the numbers as if they were volumes, and do not sum them.
const trafficValue = t => (t ? parseInt(t.replace(/[^\d]/g, ""), 10) || null : null);
const significant = trends.filter(t => (trafficValue(t.traffic) || 0) >= 500);

Which surfaces return clean data

The trending feed returns dependable structured output and is what both packages below wrap.

Interest-over-time and the comparison widgets are a different matter. They sit behind an internal token exchange rather than a public endpoint, so treat them as out of reach for a simple scraper and reach for a different signal instead.

When you need search demand with numbers attached, the Google search API paired with related searches, related questions and autocomplete gives more usable output than trends scraping does. To explain a spike rather than detect it, Google News is the natural follow-up.

Cost

Call Credits
One country trending feed 15 observed
/api/v1/usage 0
Any HTTP 500 0

Four markets polled hourly is roughly 1,440 credits a day. Check headroom first:

curl "https://app.scrapingbee.com/api/v1/usage" -H "Authorization: Bearer YOUR-API-KEY"

Tiers on the pricing page.

Ready-made packages

pip install google-trends-scraper-api
npm install google-trends-scraper-api
from google_trends_scraper_api import GoogleTrendsScraper

scraper = GoogleTrendsScraper("YOUR-API-KEY")
trends, charged = scraper.trending_with_cost("US")
print(len(trends), "trends for", charged, "credits")
print(GoogleTrendsScraper.above(trends, 500))

Both set custom_google for you, parse the feed including the nested news items, expose the parsed bucket floor, and report the credits charged.

Scope

The trending feed is public, which is the whole reason it is usable this way. Anything requiring an account is prohibited under the ScrapingBee terms. Store the API key as a secret; do not paste it into AI coding tools.

License

MIT. See LICENSE.