chromedp

A faster, simpler way to drive browsers supporting the Chrome DevTools Protocol.

Github星跟踪图

About chromedp GoDoc

Package chromedp is a faster, simpler way to drive browsers supporting the
Chrome DevTools Protocol in Go without external dependencies (like
Selenium or PhantomJS).

Installing

Install in the usual Go way:

go get -u github.com/chromedp/chromedp

Examples

Refer to the GoDoc page for the documentation and examples. Additionally,
the examples repository contains more complex examples.

Frequently Asked Questions

I can't see any Chrome browser window

By default, Chrome is run in headless mode. See DefaultExecAllocatorOptions, and
an example
to override the default options.

I'm seeing "context canceled" errors

When the connection to the browser is lost, chromedp cancels the context, and
it may result in this error. This occurs, for example, if the browser is closed
manually, or if the browser process has been killed or otherwise terminated.

Chrome exits as soon as my Go program finishes

On Linux, chromedp is configured to avoid leaking resources by force-killing
any started Chrome child processes. If you need to launch a long-running Chrome
instance, manually start Chrome and connect using RemoteAllocator.

Executing an action without Run results in "invalid context"

By default, a chromedp context does not have an executor, however one can be
specified manually if necessary; see issue #326
for an example.

I can't use an Action with Run because it returns many values

Wrap it with an ActionFunc:

chromedp.Run(ctx, chromedp.ActionFunc(func(ctx context.Context) error {
	_, err := domain.SomeAction().Do(ctx)
	return err
}))

I want to use chromedp on a headless environment

The simplest way is to run the Go program that uses chromedp inside the
chromedp/headless-shell image. That image contains headless-shell, a
smaller headless build of Chrome, which chromedp is able to find out of the
box.

Resources

主要指标

概览
名称与所有者chromedp/chromedp
主编程语言Go
编程语言Go (语言数: 3)
平台
许可证MIT License
所有者活动
创建于2017-01-24 14:54:30
推送于2025-06-20 02:34:40
最后一次提交2025-06-19 14:22:38
发布数68
最新版本名称v0.13.7 (发布于 )
第一版名称v0.1.0 (发布于 )
用户参与
星数12k
关注者数158
派生数818
提交数701
已启用问题?
问题数1314
打开的问题数143
拉请求数135
打开的拉请求数1
关闭的拉请求数117
项目设置
已启用Wiki?
已存档?
是复刻?
已锁定?
是镜像?
是私有?