# Rod — Chrome DevTools Protocol Driver for Go > A high-level Go library for controlling browsers via the Chrome DevTools Protocol, designed for web automation, scraping, and testing. ## Install Save as a script file and run: # Rod — Chrome DevTools Protocol Driver for Go ## Quick Use ```bash # Install go get github.com/go-rod/rod # Basic example # page := rod.New().MustConnect().MustPage("https://example.com") # fmt.Println(page.MustElement("h1").MustText()) ``` ## Introduction Rod is a Go library that provides a high-level API for browser automation through the Chrome DevTools Protocol (CDP). It enables developers to control Chromium-based browsers programmatically for tasks like web scraping, end-to-end testing, screenshot generation, and PDF rendering, all from native Go code. ## What Rod Does - Controls Chromium browsers programmatically for navigation, clicking, typing, and form submission - Captures screenshots and generates PDFs of web pages with full rendering fidelity - Intercepts and modifies network requests for testing and scraping scenarios - Evaluates JavaScript in the browser context and extracts DOM data - Manages browser lifecycle including headless mode, multiple tabs, and incognito contexts ## Architecture Overview Rod communicates directly with Chrome via the DevTools Protocol over WebSocket. Unlike Selenium, it does not require a separate WebDriver binary. The library auto-downloads a compatible Chromium binary on first run. Rod's API is designed around a fluent chain pattern with both must-style (panic on error) and error-returning variants for flexibility in application vs. test code. ## Self-Hosting & Configuration - Add Rod as a Go module dependency with `go get github.com/go-rod/rod` - Rod auto-manages browser binaries; set `ROD_BROWSER` env var to use a specific Chrome path - Configure headless mode, viewport size, and user-agent via the launcher options - Use `rod.New().Trace(true)` during development to log all CDP commands - Deploy in Docker using a Chromium-based image for server-side automation ## Key Features - Zero external dependencies; communicates directly via CDP without WebDriver - Auto-downloads and manages Chromium binaries for reproducible environments - Fluent API with both panic-style (Must) and idiomatic Go error handling - Built-in stealth mode helpers to reduce bot detection fingerprints - Supports concurrent page control for parallel scraping and testing ## Comparison with Similar Tools - **Playwright** — multi-language with broader browser support; Rod is Go-native and lighter - **Puppeteer** — Node.js CDP library; Rod provides the same CDP approach for Go - **Selenium/WebDriver** — requires a separate driver binary; Rod connects directly via CDP - **chromedp** — another Go CDP library; Rod offers a higher-level, more ergonomic API - **Colly** — Go web scraper without browser rendering; Rod handles JavaScript-heavy pages ## FAQ **Q: Does Rod require Chrome to be installed?** A: No. Rod automatically downloads a compatible Chromium binary on first use. You can also point it to an existing installation. **Q: Can I run Rod in a Docker container?** A: Yes. Use a Docker image with Chromium installed and set the browser path via environment variables. **Q: How does Rod compare to chromedp?** A: Rod provides a higher-level API with auto-wait, element selectors, and fluent chains. chromedp is lower-level and closer to raw CDP. **Q: Is Rod suitable for production scraping?** A: Yes. Rod supports concurrent pages, request interception, and stealth options for production-grade automation. ## Sources - https://github.com/go-rod/rod - https://go-rod.github.io --- Source: https://tokrepo.com/en/workflows/asset-cd2b9df3 Author: Script Depot