简介
通过 Scrapling 模拟真实用户行为,在无头浏览器中执行 Google 搜索并返回结构化结果,适合需要高成功率爬取的场景。
原始描述
Search Google using scrapling and return structured results (title, link, snippet). Invoke when user asks to search Google or find information online. Your d...
安装
下载 zip 解压后,把里面的文件放进你的 Agent 的 skills 目录即可使用。
给 Agent 的直链(让它自己下载安装):
https://v110.com/skill/free-google-search-with-browser.zip
Claude Code 放 ~/.claude/skills/;Codex、TypingMind 等按各自文档的 skills 目录放置。技能申请什么权限由作者决定,装前请确认。
中文使用说明 来自收录源
核心功能与用法
free-google-search-with-browser 是一款基于浏览器自动化的 Google 搜索技能,核心依赖 scrapling 库实现。它通过启动真实浏览器实例(Chromium)访问 Google,模拟人类用户的完整交互流程,从而绕过传统爬虫常见的反爬机制。
典型调用方式:
python google_search.py "<搜索关键词>"
返回结构化的 JSON 结果,包含标题、链接和摘要片段,直接适配 LLM 下游任务。配套 verify_search.py 用于快速验证环境配置与搜索功能是否正常。
显著优势
- 高成功率:相比纯 HTTP 请求方案,浏览器自动化能有效应对 Google 的动态渲染与反爬策略,返回率显著提升
- 真实环境模拟:
scrapling底层整合了playwright与curl_cffi,具备指纹伪装、TLS 指纹模拟等能力 - 结构化输出:原生支持提取标题-链接-摘要三元组,无需额外解析 HTML
- 可视化调试:
headless=False配置允许开发者实时观察浏览器行为,便于排查异常
局限性与潜在缺点
- GUI 强制依赖:
headless=False意味着必须在具备图形界面的环境中运行,无法直接部署于标准 CI/CD 或 SSH-only 服务器 - 资源开销大:浏览器实例占用内存显著高于轻量级 HTTP 客户端,并发场景下成本陡增
- 部署复杂度:需额外安装 Playwright 浏览器二进制文件(
playwright install),首次配置耗时较长 - 稳定性风险:Google 页面结构变更可能导致选择器失效,需持续维护 DOM 解析逻辑
适合人群
- 需要高可靠 Google 搜索数据的研究者与开发者
- 本地开发环境或具备 GUI 的私有服务器用户
- 对反爬对抗有较高要求、可接受资源开销的场景
常规风险提示
- IP 封禁风险:高频请求仍可能触发 Google 的风控策略,建议配合代理池与速率限制
- 环境兼容:Linux 服务器需配置
xvfb等虚拟显示方案方可运行 - 依赖维护:
scrapling与playwright版本迭代较快,锁定依赖版本以避免 breaking changes
技能正文
name: "free-google-search-with-browser" description: "Search Google using scrapling and return structured results (title, link, snippet). Invoke when user asks to search Google or find information online. Your device should be able to lanuch broswer with UI."
Google Search
This skill searches Google using a stealthy fetcher and returns structured results suitable for LLM consumption.
Usage
Run the python script google_search.py with the query as an argument.
python google_search.py "<query>"
File Structure
- google_search.py: The main script. It uses
scraplingto perform the Google search. It launches a browser instance to fetch results, ensuring high success rates by mimicking real user behavior. - verify_search.py: A debugging script. It runs a predefined set of queries to verify that the search functionality works correctly.
- requirements.txt: Lists the Python dependencies required for the project.
Requirements
- Python 3
scraplingpackage installed (withplaywrightandcurl_cffidependencies)
To install dependencies:
pip install -r requirements.txt
playwright install # Required for browser automation. If slow, consider downloading manually.
Notes & Troubleshooting
Browser Environment (Headless=False)
This skill is configured to run with headless=False (see google_search.py). This means:
- GUI Required: The environment where this code runs must support a Graphical User Interface (GUI). It will launch a visible browser window.
- No Headless Servers: It will likely fail on headless servers (like standard CI/CD runners or SSH-only servers) unless X11 forwarding or a virtual display (like
xvfb) is configured.
Debugging with verify_search.py
If you encounter issues or want to test if the setup is working:
- Run
python verify_search.py. - This script will execute several test queries (e.g., "python tutorial", mixed English/Chinese).
- Watch the browser window to see if it opens and loads Google results.
- Check the console output for success messages or error logs.
正文来自原始发布页, 版权归作者所有,许可未标注。 权利人认为有不妥,可申请下架。