Serper
Google search via Serper API. Fetches results AND reads the actual web pages to extract clean full-text content via trafilatura. Not just snippets — full article text.
Constraint
This skill already fetches and extracts full page content. Do NOT use WebFetch, web_fetch, WebSearch, browser tools, or any other URL-fetching/browsing tool on the URLs returned by this skill. The content is already included in the output. Never follow up with a separate fetch — everything you need is in the results.
Query Discipline
Craft ONE good search query. That is almost always enough.
Each call returns multiple results with full page text — you get broad coverage from a single query. Do not run multiple searches to "explore" a topic. One well-chosen query with the right mode covers it.
At most two calls if the user's request genuinely spans two distinct topics (e.g. "compare X vs Y" where X and Y need separate searches, or one default + one current call for different aspects). Never more than two.
Do NOT:
- - Run the same query with different wording to "get more results"
- Run sequential searches to "dig deeper" — the full page content is already deep
- Run one search to find something, then another to follow up — read the content you already have
Two Search Modes
There are exactly two modes. Pick the right one based on the query:
default — General search (all-time)
- - All-time Google web search, 5 results, each enriched with full page content
- Use for: general questions, research, how-to, evergreen topics, product info, technical docs, comparisons, tutorials, anything NOT time-sensitive
current — News and recent info
- - Past-week Google web search (3 results) + Google News (3 results), each enriched with full page content
- Use for: news, current events, recent developments, breaking news, announcements, anything time-sensitive
Mode Selection Guide
| Query signals | Mode |
|---|
| "how does X work", "what is X", "explain X" | INLINECODE4 |
| Product research, comparisons, tutorials |
default |
| Technical documentation, guides |
default |
| Historical topics, evergreen content |
default |
| "news", "latest", "today", "this week", "recent" |
current |
| "what happened", "breaking", "announced", "released" |
current |
| Current events, politics, sports scores, stock prices |
current |
Locale
Default is global — no country filter, English results. This ONLY works for English queries.
You MUST ALWAYS set --gl and --hl when ANY of these are true:
- - The user's message is in a non-English language
- The search query you construct is in a non-English language
- The user mentions a specific country, city, or region
- The user asks for local results (prices, news, stores, etc.) in a non-English context
If the user writes in German, you MUST pass --gl de --hl de. No exceptions.
| Scenario | Flags |
|---|
| English query, no country target | (omit --gl and --hl) |
| German query OR user writes in German OR targeting DE/AT/CH |
--gl de --hl de |
| French query OR user writes in French OR targeting France |
--gl fr --hl fr |
| Any other non-English language/country |
--gl XX --hl XX (ISO codes) |
Rule of thumb: If the query string contains non-English words, set --gl and --hl to match that language.
How to Invoke
CODEBLOCK0
Examples
CODEBLOCK1
Output Format
The script streams a JSON array. The first element is metadata, the rest are results with full extracted content:
CODEBLOCK2
| Field | Description |
|---|
| INLINECODE19 | Page title |
| INLINECODE20 |
Source URL |
|
source |
"web",
"news", or
"knowledge_graph" |
|
content | Full extracted page text (falls back to search snippet if extraction fails) |
|
date | Present when available (news results always, web results sometimes) |
CLI Reference
| Flag | Description |
|---|
| INLINECODE27 | Search query (required) |
| INLINECODE28 |
default (all-time, 5 results) or
current (past week + news, 3 each) |
|
--gl | Country code (e.g.
de,
us,
fr,
at,
ch). Default:
world |
|
--hl | Language code (e.g.
en,
de,
fr). Default:
en |
Edge Cases
- - If trafilatura cannot extract content from a page, the result falls back to the search snippet.
- Some sites block scraping entirely — the snippet is all you get.
- If zero results are returned, the script exits with
{"error": "No results found", "query": "..."}. - The Serper API key is loaded from
.env in the skill directory. If missing, the script exits with setup instructions.
Serper
通过 Serper API 进行谷歌搜索。获取搜索结果并读取实际网页,利用 trafilatura 提取干净的全文内容。不仅仅是摘要——而是完整的文章文本。
约束条件
该技能已自动获取并提取完整页面内容。请勿对该技能返回的 URL 使用 WebFetch、web_fetch、WebSearch、浏览器工具或任何其他 URL 获取/浏览工具。输出中已包含所有内容。切勿再单独发起获取请求——结果中已包含您所需的一切。
查询规范
精心设计一个优质搜索查询。这几乎总是足够的。
每次调用会返回多个包含完整页面文本的结果——单个查询即可获得广泛覆盖。不要为了探索某个主题而运行多次搜索。一个精心选择且模式正确的查询足以覆盖需求。
最多两次调用,仅当用户请求确实涉及两个不同主题时(例如比较 X 与 Y需要分别搜索 X 和 Y,或针对不同方面进行一次 default 加一次 current 调用)。绝不超过两次。
请勿:
- - 用不同措辞运行相同查询以获取更多结果
- 运行连续搜索以深入挖掘——完整页面内容已经足够深入
- 先搜索找到内容,再另一次搜索跟进——请阅读您已有的内容
两种搜索模式
共有两种模式。根据查询选择正确的模式:
default — 通用搜索(不限时间)
- - 不限时间的谷歌网页搜索,5个结果,每个结果均附带完整页面内容
- 适用于:一般问题、研究、操作指南、常青话题、产品信息、技术文档、比较、教程等非时效性内容
current — 新闻和近期信息
- - 过去一周的谷歌网页搜索(3个结果)+ 谷歌新闻(3个结果),每个结果均附带完整页面内容
- 适用于:新闻、时事、最新动态、突发新闻、公告等时效性内容
模式选择指南
| 查询信号 | 模式 |
|---|
| X 如何工作、什么是 X、解释 X | default |
| 产品研究、比较、教程 |
default |
| 技术文档、指南 | default |
| 历史话题、常青内容 | default |
| 新闻、最新、今天、本周、近期 | current |
| 发生了什么、突发、宣布、发布 | current |
| 时事、政治、体育比分、股票价格 | current |
区域设置
默认是全球范围——无国家过滤,英文结果。这仅适用于英文查询。
在以下任一情况成立时,您必须始终设置 --gl 和 --hl:
- - 用户消息为非英语语言
- 您构建的搜索查询为非英语语言
- 用户提及特定国家、城市或地区
- 用户要求非英语环境下的本地结果(价格、新闻、商店等)
如果用户使用德语书写,您必须传递 --gl de --hl de。无例外。
| 场景 | 参数 |
|---|
| 英文查询,无国家目标 | (省略 --gl 和 --hl) |
| 德语查询或用户使用德语书写或目标为 DE/AT/CH |
--gl de --hl de |
| 法语查询或用户使用法语书写或目标为法国 | --gl fr --hl fr |
| 任何其他非英语语言/国家 | --gl XX --hl XX(ISO 代码) |
经验法则: 如果查询字符串包含非英语单词,请设置 --gl 和 --hl 以匹配该语言。
如何调用
bash
python3 scripts/search.py -q 查询内容 [--mode 模式] [--gl 国家] [--hl 语言]
示例
bash
英文,通用研究
python3 scripts/search.py -q how does HTTPS work
英文,时效性
python3 scripts/search.py -q OpenAI latest announcements --mode current
德语查询——设置区域 + 新闻/价格使用 current 模式
python3 scripts/search.py -q aktuelle Preise iPhone --mode current --gl de --hl de
德语新闻
python3 scripts/search.py -q Nachrichten aus Berlin --mode current --gl de --hl de
法语产品研究
python3 scripts/search.py -q meilleur smartphone 2026 --gl fr --hl fr
输出格式
脚本输出一个 JSON 数组。第一个元素是元数据,其余是包含完整提取内容的结果:
json
[{query: ..., mode: default, locale: {gl: world, hl: en}, results: [{title: ..., url: ..., source: web}]}
,{title: 页面标题, url: https://example.com, source: web, content: 完整提取的页面文本...}
,{title: 新闻文章, url: https://news.com, source: news, date: 2小时前, content: 完整文章文本...}
]
来源 URL |
| source | web、news 或 knowledge_graph |
| content | 完整提取的页面文本(提取失败时回退到搜索摘要) |
| date | 可用时显示(新闻结果始终有,网页结果有时有) |
CLI 参考
| 参数 | 描述 |
|---|
| -q, --query | 搜索查询(必填) |
| -m, --mode |
default(不限时间,5个结果)或 current(过去一周+新闻,各3个) |
| --gl | 国家代码(例如 de、us、fr、at、ch)。默认:world |
| --hl | 语言代码(例如 en、de、fr)。默认:en |
边界情况
- - 如果 trafilatura 无法从页面提取内容,结果将回退到搜索摘要。
- 某些网站完全阻止抓取——您只能获得摘要。
- 如果返回零结果,脚本退出并输出 {error: No results found, query: ...}。
- Serper API 密钥从技能目录中的 .env 文件加载。如果缺失,脚本退出并显示设置说明。