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.
How It Works
- 1. Serper API call — fast Google search, returns result URLs instantly
- Concurrent page scraping — all result pages are fetched and extracted in parallel using trafilatura with a 3-second timeout per page
- Streamed output — results print one at a time as each page finishes
Each invocation gives you 5 results (default mode) or up to 6 results (current mode), each with full page content. This is already a lot of information.
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
When to Use This Skill
Use serper when:
- - Any question that needs current, factual information from the web
- Research topics that need full article content, not just snippets
- News and current events
- Product info, prices, comparisons, reviews
- Technical docs, how-to guides
- Anything where reading the actual page matters
Do NOT use this skill for:
- - Questions you can answer from your training data
- Pure math, code execution, creative writing
- Greetings, chitchat
IMPORTANT: This skill already fetches and extracts full page content. Do NOT use web_fetch, WebFetch, or any other URL-fetching tool on the URLs returned by this skill. The content is already included in the output.
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 (REQUIRED for non-English queries)
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 output is a streamed JSON array — elements print one at a time as each page is scraped:
CODEBLOCK2
The first element is search metadata. Each following element contains a result with full extracted content.
Result fields:
- -
title — page title - INLINECODE20 — source URL
- INLINECODE21 —
"web", "news", or INLINECODE24 - INLINECODE25 — full extracted page text (falls back to search snippet if extraction fails)
- INLINECODE26 — 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) |
|
--hl | Language code (e.g.
en,
de,
fr) |
Serper
通过Serper API进行Google搜索。获取搜索结果并读取实际网页,使用trafilatura提取干净的全文内容。不仅仅是摘要——而是完整的文章文本。
工作原理
- 1. Serper API调用 — 快速Google搜索,立即返回结果URL
- 并发页面抓取 — 所有结果页面并行获取,使用trafilatura提取内容,每个页面超时3秒
- 流式输出 — 每个页面完成时逐个打印结果
每次调用可获得5个结果(默认模式)或最多6个结果(当前模式),每个结果包含完整页面内容。这已经是大量信息。
查询规范
精心设计一个优秀的搜索查询。这几乎总是足够的。
每次调用返回多个结果及完整页面文本——单个查询即可获得广泛覆盖。不要为了探索某个主题而运行多次搜索。一个精心选择的查询配合正确的模式即可覆盖需求。
最多两次调用,仅当用户的请求确实涉及两个不同的主题时(例如比较X与Y,其中X和Y需要分别搜索,或针对不同方面分别进行一次default和一次current调用)。绝不超过两次。
不要:
- - 用不同措辞运行相同查询以获取更多结果
- 运行连续搜索以深入挖掘——完整页面内容已经足够深入
- 先搜索找到某内容,再搜索跟进——阅读已有的内容即可
何时使用此技能
使用serper的场景:
- - 任何需要来自网络的当前、事实性信息的问题
- 需要完整文章内容而不仅仅是摘要的研究主题
- 新闻和时事
- 产品信息、价格、比较、评论
- 技术文档、操作指南
- 任何需要阅读实际页面的内容
不要使用此技能的场景:
- - 可以从训练数据中回答的问题
- 纯数学、代码执行、创意写作
- 问候、闲聊
重要提示:此技能已获取并提取完整页面内容。不要对此技能返回的URL使用web_fetch、WebFetch或任何其他URL获取工具。内容已包含在输出中。
两种搜索模式
共有两种模式。根据查询选择正确的模式:
default — 通用搜索(全部时间)
- - 全部时间的Google网页搜索,5个结果,每个结果附带完整页面内容
- 适用于:一般问题、研究、操作指南、常青主题、产品信息、技术文档、比较、教程、任何非时间敏感的内容
current — 新闻和近期信息
- - 过去一周的Google网页搜索(3个结果)+ Google新闻(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 HTTPS如何工作
英文,时间敏感
python3 scripts/search.py -q OpenAI最新公告 --mode current
德语查询 — 设置区域 + 当前模式用于新闻/价格
python3 scripts/search.py -q aktuelle Preise iPhone --mode current --gl de --hl de
德语新闻
python3 scripts/search.py -q 柏林新闻 --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: ..., source: web, content: 完整提取的页面文本...}
,{title: ..., url: ..., source: news, date: 2小时前, content: 完整文章文本...}
]
第一个元素是搜索元数据。后续每个元素包含一个结果及完整提取的内容。
结果字段:
- - title — 页面标题
- url — 来源URL
- source — web、news或knowledge_graph
- content — 完整提取的页面文本(如果提取失败则回退到搜索摘要)
- date — 可用时显示(新闻结果始终有,网页结果有时有)
CLI参考
| 参数 | 描述 |
|---|
| -q, --query | 搜索查询(必填) |
| -m, --mode |
default(全部时间,5个结果)或current(过去一周+新闻,各3个) |
| --gl | 国家代码(例如de、us、fr、at、ch) |
| --hl | 语言代码(例如en、de、fr) |