如何用 Apify 將 Google Trends 數據每日寫入 Google Sheets
Send Google Trends data to Google Sheets every morning (no pytrends, no 429 errors)
這篇教學示範如何用 Apify 的 Google Trends Scraper,將關鍵字熱度、上升相關查詢及指定國家的每日熱門搜尋定時寫入 Google Sheets。
If you have ever tried to pull Google Trends data with code, you probably know this message:
pytrends.exceptions.TooManyRequestsError: The request failed: Google returned a response with code 429
pytrends, the library almost everyone used, was archived on GitHub in April 2025. Nobody ships fixes anymore, and Google rate-limits it quickly: it works for a while, then the 429s start.
Most articles stop at "pytrends is dead, here are some alternatives". This one solves one concrete job instead:
Every morning, put fresh Google Trends numbers for my keywords — plus today's trending searches in my country — into a Google Sheet.
No server, no cron job, no proxy management. Then I'll show the same thing in 10 lines of Python for people who prefer code.
What we will build
A Google Sheet that refreshes itself daily with:
-
Interest over time (0–100) for your keywords, for example
chatgpt,claude,gemini - Rising related queries — the "Breakout" searches you want to catch early
- Today's trending searches in a country, with traffic estimates and news links
We'll use the Google Trends Scraper on Apify. Disclosure: I built it, because I needed exactly this and got tired of babysitting 429 errors. It handles retries and rotating IPs, and it only charges for results it actually returns.
Step 1: Run it once
- Open the Actor page and click Try for free. The free Apify plan includes $5 of monthly credit, which is enough for this whole tutorial.
- In Search terms, add your keywords (up to 5 per comparison group).
- Turn on Compare terms on one chart if you want them on the same 0–100 scale, like on the Trends website.
- Set Country / region code (e.g.
US,GB,DE) and Time range (e.g.Past 30 days). - In Trending now: countries, add
US(or any country) to also get today's trending searches. - Click Start.
After a few seconds you get items like this:
{
"type": "search",
"searchTerms": ["chatgpt", "claude", "gemini"],
"geo": "US",
"interestOverTime": [
{ "date": "2026-10-19T00:00:00Z", "values": { "chatgpt": 85, "claude": 24, "gemini": 38 } }
],
"relatedQueries": {
"gemini": { "rising": [{ "query": "gemini argon 4", "value": "Breakout" }] }
}
}
You can download this as CSV or Excel straight from the Output tab.
Step 2: Schedule it
- Click Actions → Save as a new task, so your keywords and settings are saved.
- On the task page, open Schedules and create a schedule, for example every day at 07:00.
From now on it runs every morning by itself.
Step 3: Send results to Google Sheets
On the task, open the Integrations tab and add the Google Sheets integration. Connect your Google account, choose a spreadsheet and map the output. After each scheduled run, the new rows land in your sheet.
That's it: a self-updating trends dashboard, without writing or hosting any code. From there it's easy to add a chart in Sheets, or let Zapier, Make or n8n post the "Breakout" queries to Slack.
The Python version (10 lines)
If you'd rather stay in code, the official apify-client package runs the same scraper and gives you the results. Get your API token from Apify Console → Settings → API & Integrations.
pip install apify-client
from apify_client import ApifyClient
client = ApifyClient("YOUR_APIFY_TOKEN")
run = client.actor("trendcraft/google-trends-scraper").call(run_input={
"searchTerms": ["chatgpt", "claude", "gemini"],
"compareTerms": True,
"geo": "US",
"timeframe": "today 1-m",
"trendingNowGeos": ["US"],
})
for item in client.dataset(run["defaultDatasetId"]).iterate_items():
if item["type"] == "search":
latest = item["interestOverTime"][-1]
print(latest["date"], latest["values"])
else: # trendingNow
print(item["rank"], item["title"], item["approxTraffic"])
Load it into pandas with pd.DataFrame(...) and you're back to the workflow you had with pytrends, minus the 429s.
When you don't need this
To be honest: if you only check a handful of keywords now and then, a free library may be enough. trendspy and trendspyg are maintained alternatives to pytrends and are worth trying first.
A hosted scraper makes sense when:
- the job has to run every day without failing (reports, dashboards, alerts),
- you track hundreds of keywords, so rate limits hit you constantly,
- you want results in Sheets, Zapier, Make or n8n without running a server.
Cost
You pay per result: one result per keyword (or per comparison group of up to 5 keywords) and one per trending search. Current pricing is on the Actor's Pricing tab. Example: a daily run with 5 compared keywords (1 result) plus one country's trending list (about 20 results) is roughly 630 results a month, which is about $3 at $5 per 1,000 results, so it fits inside the free $5 monthly credit. Skip the trending list and it drops to cents.
If you try it and something breaks, or you need a field that isn't there, open an issue on the Actor's Issues tab. I read them all.
This post was drafted with AI assistance; input names and output fields were checked against the Actor itself.
來源:DEV Community · dev.to