bugrahans's picture
Upload 4 files
a86ae8d verified
|
Raw History Blame Contribute Delete
3.46 kB
---
title: Google Trends Scraper
short_description: Google Trends API alternative — interest, compare, trending
emoji: 📈
colorFrom: blue
colorTo: red
sdk: gradio
sdk_version: 6.0.2
app_file: app.py
pinned: false
tags:
- google-trends
- google-trends-api
- google-trends-scraper
- pytrends
- pytrends-alternative
- trending-searches
- keyword-research
- seo
- marketing
- web-scraping
- scraper
- data-extraction
- smolagents
- tool
- scrape.do
---
# Google Trends Scraper — Powered by Scrape.do
Google Trends data as clean JSON and CSV: interest over time, interest by
country, state or city, top and rising related searches, keyword comparisons,
and what's trending right now in any country.
The unofficial **pytrends** library is no longer maintained, and Google's own
Trends API is still invite-only. This Space runs on the
[Scrape.do Google Trends API](https://scrape.do/documentation/google-scraper-api/trends/),
which handles Google's rate limits and returns the same field names every time.
## 🔑 Get your free API token
👉 **[Sign up free on Scrape.do](https://dashboard.scrape.do/sign-up?utm_source=huggingface&utm_medium=google-trends-scraper)** — 1,000 free credits per month, no credit card required. Every Google Trends call costs 10 credits, so that's about 100 calls.
## Three tabs
| Tab | Input | Output |
| --- | --- | --- |
| **Explore a keyword** | One keyword, place, time range, search type | Interest-over-time chart, interest by region, top and rising related searches and topics, two CSVs |
| **Compare keywords** | 2–5 keywords | All of them on one 0–100 scale, who leads overall and in each region, CSV |
| **Trending now** | Country, time window, category | Today's trending searches with search volume, growth, related searches and status, CSV |
Time ranges: past 7 days, 30 days, 90 days, 12 months, 5 years, 2004–present,
or any custom range such as `2024-01-01 2024-12-31`. Search types: web,
YouTube, News, Images and Google Shopping.
## Use as a smolagents Tool
```python
from smolagents import CodeAgent, InferenceClientModel
from tool import ScrapeDoGoogleTrendsTool
agent = CodeAgent(
tools=[ScrapeDoGoogleTrendsTool(api_token="YOUR_SCRAPEDO_TOKEN")],
model=InferenceClientModel(),
)
agent.run("Compare interest in ChatGPT, Claude and Gemini in the US over the past 12 months, then list what's trending in Technology right now.")
```
You can also set `SCRAPE_DO_API_TOKEN` in your environment and instantiate
`ScrapeDoGoogleTrendsTool()` with no arguments.
## Inputs
- `mode` *(required)* — `explore`, `compare`, `related_topics` or `trending`.
- `query` *(optional)* — The keyword. For `compare`, up to 5 separated by commas. Not used for `trending`.
- `geo` *(optional)* — Country or region code: `US`, `GB`, `TR`, `US-CA`… Empty means worldwide. `trending` defaults to `US`.
- `date` *(optional)* — `7d`, `30d`, `90d`, `12m` (default), `5y`, `all`, or Google's format such as `today 3-m` or `2024-01-01 2024-12-31`.
- `search_type` *(optional)* — `web`, `youtube`, `news`, `images` or `shopping`.
- `category` *(optional, trending)* — Category id, e.g. `17` Sports, `18` Technology, `3` Business and Finance.
- `hours` *(optional, trending)* — `4`, `24`, `48` or `168`.
---
Learn more at [scrape.do](https://scrape.do/) · [Documentation](https://scrape.do/documentation/) · [Google Trends API docs](https://scrape.do/documentation/google-scraper-api/trends/)