go-rod-master
使用go-rod自动化浏览器和抓取网站
在Go语言中遇到机器人检测和复杂的浏览器自动化问题?本技能提供生产环境就绪的无头浏览器控制模式,内置隐身功能。
下载技能 ZIP
在 Claude 中上传
前往 设置 → 功能 → 技能 → 上传技能
开启并开始使用
测试它
正在使用“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
安全审计
低风险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.
低风险问题 (4)
风险因素
⚙️ 外部命令 (2)
质量评分
你能构建什么
网页抓取管道
为通过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()——路由器必须启动