mcpField
G
google-trends

google-trends

github.com/ezcat207数据与数据库138 次安装34 周前更新
代码仓库

关于 google-trends

此技能可按国家、类别和时间范围获取当前 Google Trends 搜索趋势。它运行脚本,并以排名和搜索量数据呈现结果。

主要功能

  1. 01按国家获取趋势
  2. 02按类别筛选
  3. 03选择时间范围
  4. 04设置结果数量
  5. 05以 JSON 返回趋势排名

适用场景

  1. 01查看某个国家的热门搜索
  2. 02了解特定主题的趋势
  3. 03比较不同国家的搜索趋势
  4. 04整理趋势排名表

安装

复制下面的命令,在终端中运行。

$npx skills add https://github.com/ezcat207/google-trends-skill --skill google-trends

安装后在 Claude Code 中输入/google-trends确认已加载。

包含的文件

除 SKILL.md 外,安装时一起下载的参考资料和脚本。

.security-scan-passed
requirements.txt
scripts/
run.py
trends.py

详细介绍

Google Trends 技能

从 Google Trends 获取任意国家和类别的实时热门搜索。

何时使用此技能

在以下情况下触发:

  • 询问“[国家] 有什么热门趋势?”
  • 询问“[国家] 的热门[游戏/AI/科技/体育等]”
  • 表示“[国家] 的 Google Trends”
  • 想比较不同国家的趋势
  • 调用 /google-trends

参数

标志默认值选项
--geoUS任意 2 位国家代码:US、BR、ID、GB、JP、IN、DE、FR、AU、MX、……
--categoryallall、games、technology、sports、entertainment、business、health、science、food、travel、beauty、politics、shopping
--hours244、24、48、168(7 天)
--top20任意整数
--methodautorss(速度快,不支持类别筛选)、csv(Selenium,支持类别筛选)

自动方法逻辑: 当 --category all 时使用 rss,指定具体类别时使用 csv。

国家代码参考

国家代码国家代码
巴西BR印度尼西亚ID
美国US印度IN
英国GB日本JP
德国DE法国FR
澳大利亚AU墨西哥MX
加拿大CA韩国KR
阿根廷AR尼日利亚NG
菲律宾PH泰国TH

脚本执行

重要: 始终使用 run.py 包装器。它会自动处理虚拟环境设置。

基本用法(一般趋势,速度快)
python scripts/run.py --geo BR
按类别筛选趋势(使用 Selenium)
python scripts/run.py --geo BR --category games
python scripts/run.py --geo ID --category technology
python scripts/run.py --geo US --category sports --hours 48
多个国家(并行运行)
python scripts/run.py --geo BR --category games &
python scripts/run.py --geo ID --category games &
wait
显示前 N 条结果并延长时间范围
python scripts/run.py --geo JP --category entertainment --hours 168 --top 30

工作流

  1. 解析用户意图 → 提取国家、类别和时间范围
  2. 映射到参数:
    • “巴西” → --geo BR
    • “印度尼西亚” → --geo ID
    • “游戏” → --category games
    • “AI/科技/技术” → --category technology
    • “过去一周”/“7 天” → --hours 168
  3. 告知用户:“正在获取[国家]的[类别]趋势(过去 [N] 小时)……”
  4. 运行脚本并解析 JSON 输出
  5. 呈现结果为包含排名、趋势名称和搜索量的格式化表格

输出格式

脚本输出 JSON:

{
  "geo": "BR",
  "category": "games",
  "hours": 24,
  "method": "csv",
  "count": 20,
  "trends": [
    {"rank": 1, "trend": "grêmio x internacional", "volume": "500K+", "started": "..."},
    {"rank": 2, "trend": "arsenal x chelsea", "volume": "500K+", "started": "..."}
  ]
}

呈现结果

将输出整理为简洁的 Markdown 表格:

## 🔥 Trending in Brazil — Games (past 24h)

| # | Trend | Volume |
|---|-------|--------|
| 1 | grêmio x internacional | 500K+ |
| 2 | arsenal x chelsea | 500K+ |
...

如有需要,在表格后补充简短背景或见解(例如:“足球在巴西的热门游戏趋势中占主导地位——格雷米奥与国际队之间的格雷纳尔德比引发了最大的搜索量激增。”)。

错误处理

错误操作
BrowserError/超时使用 --method rss 重试(会取消类别筛选)
InvalidParameterError检查地理代码或类别名称
虚拟环境设置失败检查是否安装了 Python 3.8+
未返回趋势尝试更宽泛的类别或不同的时间范围

故障排除

  • CSS 方法速度慢:这是正常现象——Selenium 会以无头模式启动 Chrome
  • RSS 方法下类别筛选不起作用:RSS 不支持类别筛选,请使用 --method csv
  • 结果为空:尝试设置 --hours 168,扩大时间范围
  • 未找到国家:运行 python scripts/run.py --list-countries 查看所有支持的代码

评论

支持 Markdown