技能 go-rod-master
📦

go-rod-master

低风险 🌐 网络访问⚙️ 外部命令

使用go-rod自动化浏览器和抓取网站

在Go语言中遇到机器人检测和复杂的浏览器自动化问题?本技能提供生产环境就绪的无头浏览器控制模式,内置隐身功能。

支持: Claude Codex Code(CC)
📊 70 充足
1

下载技能 ZIP

2

在 Claude 中上传

前往 设置 → 功能 → 技能 → 上传技能

3

开启并开始使用

测试它

正在使用“go-rod-master”。 导航到GitHub并提取仓库信息

预期结果:

页面标题:GitHub: Let's build from here
找到页面上的127个链接
搜索结果:go-rod/rod - DevTools Protocol driver for Go

正在使用“go-rod-master”。 验证隐身模式通过机器人检测测试

预期结果:

截图已保存到stealth_result.png
用户代理:通过
WebDriver:缺失(通过)
Chrome:存在(通过)
插件数量:3
语言:en-US,en

安全审计

低风险
v1 • 2/25/2026

Static analysis detected 279 potential issues but all are false positives from pattern matching on markdown documentation and Go import statements. The 'external_commands' findings are markdown table separators (|), not shell execution. The 'scripts' findings are Go import statements, not JavaScript. Network findings are example URLs in documentation, which is expected for a browser automation tutorial. One critical finding for 'keylogger keywords' at SKILL.md:515 references legitimate keyboard input simulation (page.Keyboard.MustType) for browser automation, not malicious keylogging. Screen capture findings reference screenshot functionality for testing. Overall risk is low due to legitimate browser automation use case with proper resource cleanup patterns documented.

6
已扫描文件
996
分析行数
6
发现项
1
审计总数
低风险问题 (4)
Network requests to external URLs
Example code contains hardcoded URLs for demonstration purposes. This is expected behavior for a browser automation tutorial skill.
Keyboard input simulation capability
The skill documents keyboard input methods (MustType, MustPress) which could theoretically be misused but are standard browser automation APIs.
Screenshot and screen capture functionality
Documentation includes screenshot methods (MustScreenshot, ScrollScreenshot) which capture page content.
Proxy configuration support
Documentation shows SOCKS5 proxy configuration for routed traffic, which could enable traffic obfuscation.
审计者: claude

质量评分

41
架构
100
可维护性
87
内容
50
社区
82
安全
78
规范符合性

你能构建什么

网页抓取管道

为通过AJAX加载内容的动态JavaScript密集型网站构建可靠的抓取器。使用隐身模式避免检测,使用页面池进行并发抓取。

自动化测试

为Web应用程序创建端到端浏览器测试,包含适当的等待策略、元素交互和用于视觉回归的截图捕获。

机器人检测研究

通过比较应用隐身规避前后的指纹结果来研究和测试反机器人检测系统。

试试这些提示

基础网页抓取
编写一个使用go-rod的Go脚本,导航到新闻网站,等待页面加载,提取所有文章标题及其链接。包含适当的错误处理和资源清理。
带反检测的隐身抓取
网络请求拦截
构建一个go-rod脚本,拦截单页应用程序发出的所有API调用,记录请求/响应数据,并修改响应体以注入自定义JavaScript跟踪代码。
并发页面池抓取器
使用rod.PagePool实现高性能抓取器,以最多5个并发页面的方式并发处理100+个URL的列表。包含结果聚合、错误处理和适当的清理。

最佳实践

  • 对于实际网站,始终使用stealth.MustPage()而不是browser.MustPage()以避免机器人检测
  • 连接后立即使用defer browser.MustClose()以确保即使发生错误也能清理
  • 用Rod的内置等待方法(如MustWaitStable()和MustWaitRequestIdle())替换time.Sleep()调用

避免

  • 为每个任务创建一个新的Browser实例——创建一个Browser并使用多个Page实例
  • 在生产代码中使用Must*方法——使用返回错误的方法进行显式错误处理
  • 忘记在设置劫持路由后调用go router.Run()——路由器必须启动

常见问题

如何在不下载Chromium的情况下运行go-rod?
使用launcher.NewBrowser().MustGet()进行预下载,或设置Launcher.Leakless(false)选项。您还可以使用其WebSocket URL通过rod.New().ControlURL(wsURL).MustConnect()连接到现有的Chrome实例。
为什么使用隐身模式后仍然被Cloudflare检测到?
Stealth处理常见指纹,但高级系统可能需要额外措施:使用住宅代理、在操作之间添加类似人类的延迟、随机化视口大小,并实施随机滚动和悬停等行为模式。
如何处理iframe和shadow DOM元素?
使用page.MustSearch()而不是page.MustElement()——它像DevTools Ctrl+F一样跨所有iframe和shadow DOM边界搜索。或者,首先使用page.MustElement("iframe").MustFrame()切换到iframe上下文。
MustWaitLoad()和MustWaitRequestIdle()有什么区别?
MustWaitLoad()等待页面加载事件,而MustWaitRequestIdle()等待直到没有待处理的网络请求。对于AJAX密集型页面,MustWaitRequestIdle()更可靠,因为内容可能在初始页面加载后加载。
我可以在go-rod中使用Chrome扩展程序吗?
可以,但扩展程序需要有头模式。使用launcher.New().Set("load-extension","/path/to/extension").Headless(false).MustLaunch()加载扩展程序。无头模式不支持扩展程序。
如何处理文件下载?
使用browser.MustDownload()返回的等待函数。在触发下载之前调用它,然后在点击下载链接后,调用等待函数获取下载的文件数据作为字节切片。