Coding

Free Web Search

Search Bing CN or DuckDuckGo and optionally extract page text into structured results.

What it does

Search the web through Bing CN or DuckDuckGo and return up to 20 results, with optional body extraction for the first five pages. A Playwright-based Python script selects an engine from IP location, falls back if one engine fails, and supports manual region overrides. It defaults to Chinese-oriented results and only runs when the user explicitly requests web search.

When to use it

  • Chinese-language technical research
  • Current web information lookup
  • Search with selected-page text extraction
  • Region-specific Bing CN or DuckDuckGo queries

The skill document

free-web-search 联网搜索工具

基于 Playwright 的 Bing 国内版 / DuckDuckGo 搜索工具。专注于搜索 + 可选正文抓取两件事,无副作用。

触发方式

仅在用户明确请求联网搜索时调用,例如:

  • "用 free-web-search 查一下 Python 异步教程"
  • "联网搜索 2026 年中国大型邮轮"
  • "web search: latest LLM benchmarks"

trigger_keywords 已经收窄到只识别 free-web-search联网搜索网页搜索web search,不会因为消息里出现"新闻"、"最新消息"这些常见词就把对话内容发到外部搜索引擎。

核心能力

  • 中文环境优化:默认 mkt=zh-CN,结果以中文为主
  • 可选全文抓取:通过 --full=N 抓取前 N 条结果正文(默认 0 不抓取)
  • 智能路由:基于 IP 地理位置自动选择 Bing CN(国内)或 DuckDuckGo(国外),单引擎失败时自动兜底
  • Headless 浏览器:服务器/容器可用,仅开 --no-sandbox--disable-gpu--disable-dev-shm-usage 三个标准稳定性参数

安装

所有依赖必须在使用前手动安装。脚本运行时不会自动安装任何 npm/pip 包,也不会修改宿主环境。

前置依赖

依赖用途备注
Python 3.8+运行时
playwright浏览器自动化pip install playwright
ChromiumPlaywright 浏览器引擎playwright install chromium(约 150 MB)

一键安装

# Linux / macOS
bash scripts/setup.sh

手动安装

pip install playwright
playwright install chromium

使用示例

# 基础搜索(不抓正文)
python scripts/web_search.py "Python 异步编程 最佳实践 2026" --max=10

# 搜索 + 抓前 3 条全文
python scripts/web_search.py "中国大型邮轮 花城号 出坞" --full=3

# 手动指定区域(代理用户)
python scripts/web_search.py "技术教程" --region=cn    # 强制 Bing CN
python scripts/web_search.py "技术教程" --region=intl  # 强制 DuckDuckGo

搜索 Query 优化建议

搜索效果取决于 Query 是否合理:

  1. 简洁精准:2-5 个核心词组合,避免长句、反问句
  2. 限定明确:需要时效性/地区内容时加上对应限定词
  3. 格式正确:中文关键词 + 数字/英文限定词
场景推荐不推荐
时效新闻2026年04月 美伊局势最近美伊之间发生了什么
技术教程Python 异步编程 2026我想学 Python 异步编程
本地内容广东东莞 今日天气东莞今天天气怎么样啊
官方信息华为云 ModelArts 文档华为云那个 ModelArts 怎么看

参数说明

参数类型默认范围说明
query字符串必填搜索关键词
--max整数101-20最多返回条数
--full整数00-5抓取前 N 条全文
--region字符串autoauto/cn/intl区域覆盖(auto = IP 探测,cn = Bing CN,intl = DuckDuckGo)

隐私与网络说明

启用此工具会产生以下出站请求,使用前请确认你的环境允许:

目的端点数据
IP 地理位置探测myip.ipip.net, cip.cc, ipinfo.io/json, ipapi.co/json你的 IP、UA
Bing 搜索(国内 IP 默认)cn.bing.com你的 query 文本、IP、UA
DuckDuckGo 搜索(国外 IP 默认)duckduckgo.com你的 query 文本、IP、UA
抓取目标页(仅当 --full > 0各搜索结果对应的站点你的 IP、UA、Referer

工具本身:

  • 不收集 telemetry、不写日志到第三方
  • 不在运行时安装 pip 包、不修改宿主目录之外的文件
  • 浏览器 cookie 仅在当前 Playwright 上下文内使用,进程退出即销毁

如果你不希望抓取目标页,把 --full 留在默认值 0 即可,工具只会访问搜索引擎和 IP 探测服务。

与 free-web-search-js 的区别

free-web-search(本工具):

  • 轻量级 Python 实现,无需 Node.js
  • 依赖 Playwright + Chromium(~150 MB)
  • 适合简单查询、快速结果
  • 不支持复杂 JS 渲染的单页应用

free-web-search-js

  • 基于 Puppeteer 的 Node.js 实现
  • 完整浏览器环境,支持重度 JS 渲染
  • 适合需要完整 DOM 交互的场景

选择建议:优先使用本工具(free-web-search),仅在遇到 JS 渲染问题时切换到 free-web-search-js。

测试

当前版本无自动化测试覆盖。欢迎贡献测试用例。

常见问题

搜索返回空结果

  • 检查网络(Bing 国内版偶发限流,工具已内置 3s 节流和指数退避)
  • 如果在国外但被误判为国内,试 --region=intl 强制 DuckDuckGo
  • 检查 query 是否过于冗长

浏览器启动失败

脚本不会自动安装。手动跑:

pip install playwright
playwright install chromium

全文抓取失败

  • 部分站点 JS 渲染较重或返回非 HTML,工具不会做特殊处理
  • 考虑使用 free-web-search-js(基于 Puppeteer,JS 渲染能力更强)

IP 探测失败或被误判

  • 工具依次探测 4 个公开 IP 服务(myip.ipip.net、cip.cc、ipinfo.io、ipapi.co)
  • 如果所有探测失败,默认使用 DuckDuckGo(国外)
  • 可通过 --region=cn--region=intl 手动覆盖

已知限制

  • VPN/代理:可能影响 Bing 国内版的可达性
  • headless:默认 headless=True,无 GUI 依赖
  • DDG 国内不可达:DuckDuckGo 在中国大陆需要科学上网,超时单次 10s 快速失败
  • 抓取上限--full 最多 5 条,单页正文截断到 8000 字

Questions people ask

What do I need to install before running it?
Install Python 3.8+, Playwright, and Chromium manually. The script does not install packages at runtime or modify files outside its host directory.
Can it fetch the full text of search results?
Yes. Set `--full=N` to fetch the bodies of the first N results, where N is 0–5; the default is 0, and each page is truncated to 8,000 characters.
How does it choose between Bing CN and DuckDuckGo?
In `auto` mode, it detects IP location and routes domestic traffic to Bing CN and international traffic to DuckDuckGo, with fallback on engine failure. Use `--region=cn` or `--region=intl` to override the choice.

Related skills

Automate browser interactions, extract page data, and replay saved browser tasks from a CLI.

50 installs4 stars

Research, analyze, and operate Xiaohongshu content through a JSON-capable CLI.

86 installs2 stars

Research recent discussions across Reddit, X, YouTube, and the web, then synthesize cited findings.

110 installs

Turns content into quotable answer blocks and reports GEO scores, query coverage, and citation readiness.

127 installs7 stars

Turn trip requirements and current travel research into a tailored itinerary in PDF, HTML, or Markdown.

59 installs1 stars

Route Markdown articles through preview, conversion, image-post, and WeChat draft workflows with readiness checks.

65 installs4 stars