Configs2026年7月1日·1 分钟阅读

Chromedp — Drive Browsers with the Chrome DevTools Protocol in Go

Pure Go library for controlling browsers via the Chrome DevTools Protocol, without external dependencies like Selenium or PhantomJS.

Agent 就绪

Agent 可直接安装

这个资产可安装;Agent 先选择当前运行时、检查安装计划,再运行匹配命令。

Native · 98/100策略:允许
Agent 入口
任意 MCP/CLI Agent
类型
Skill
安装
Single
信任
信任等级:Established
入口
Chromedp
直接安装命令
npx -y tokrepo@latest install 0eaccd35-754d-11f1-9bc6-00163e2b0d79 --target codex

先 dry-run 确认安装计划,再运行此命令。

Introduction

Chromedp is a pure Go package for driving browsers using the Chrome DevTools Protocol (CDP). It provides a high-level API for navigating pages, filling forms, clicking elements, taking screenshots, and extracting data, all without requiring Selenium, WebDriver, or any external binary dependencies beyond a Chrome or Chromium installation.

What Chromedp Does

  • Controls Chrome and Chromium browsers programmatically via CDP
  • Navigates pages, clicks elements, fills forms, and submits data
  • Takes full-page and element-level screenshots in PNG format
  • Evaluates JavaScript in the browser context and retrieves results
  • Captures network events, console logs, and DOM snapshots

Architecture Overview

Chromedp communicates with the browser over a WebSocket connection using the Chrome DevTools Protocol. It manages browser process lifecycle (launching, connecting, and closing), creates browser contexts and tabs, and translates high-level actions into sequences of CDP commands. Everything runs in-process as a Go library with no CGo or external binary dependencies.

Self-Hosting & Configuration

  • Add to your Go project with go get github.com/chromedp/chromedp
  • Requires Chrome or Chromium installed on the host (or use a headless Docker image)
  • Configure browser launch flags via chromedp.Flag options (headless, proxy, window size)
  • Use chromedp.NewRemoteAllocator to connect to an existing browser or remote debugging port
  • Set timeouts and contexts using standard Go context.Context patterns

Key Features

  • Zero external dependencies beyond Chrome/Chromium itself
  • Composable action API chains multiple browser operations in a single Run call
  • Full CDP access for advanced use cases (network interception, performance tracing)
  • Headless and headed modes for testing and debugging
  • Supports concurrent browser contexts for parallel scraping or testing

Comparison with Similar Tools

  • Selenium — Requires WebDriver binaries and language bindings; chromedp is a single Go import
  • Puppeteer — Node.js CDP library; chromedp brings the same concept to Go
  • Playwright — Multi-browser automation in JS/Python; chromedp is Go-native and Chrome-focused
  • Rod — Another Go CDP library with auto-download; chromedp has a larger community
  • Colly — Go web scraping framework using HTTP; chromedp renders JavaScript pages

FAQ

Q: Does chromedp work in headless mode? A: Yes. By default, chromedp launches Chrome in headless mode. You can switch to headed mode for debugging.

Q: Can I use chromedp for end-to-end testing? A: Yes. Many teams use chromedp for browser-based integration tests in Go projects.

Q: Does chromedp support file downloads? A: Yes. You can configure the download directory and intercept download events via CDP.

Q: Is chromedp compatible with Docker? A: Yes. Use a headless Chrome Docker image and connect chromedp via the remote debugging port.

Sources

讨论

登录后参与讨论。
还没有评论,来写第一条吧。

相关资产