MyGit

chromedp/chromedp

Fork: 788 Star: 11019 (更新于 2024-11-03 07:55:44)

license: MIT

Language: Go .

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

最后发布版本: v0.9.2 ( 2023-08-05 12:42:40)

GitHub网址

About chromedp

Package chromedp is a faster, simpler way to drive browsers supporting the Chrome DevTools Protocol in Go without external dependencies.

Unit Tests Go Reference Releases

Installing

Install in the usual Go way:

$ go get -u github.com/chromedp/chromedp

Examples

Refer to the Go reference for the documentation and examples. Additionally, the examples repository contains more examples on complex actions, and other common high-level tasks such as taking full page screenshots.

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:

ctx, cancel := chromedp.NewContext(context.Background())
defer cancel()
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

最近版本更新:(数据更新于 2024-09-13 13:31:42)

2023-08-05 12:42:40 v0.9.2

2023-04-15 10:24:18 v0.9.1

2023-03-11 06:29:09 v0.9.0

2023-03-05 21:05:56 v0.8.8

2023-01-10 13:01:57 v0.8.7

2022-11-02 12:27:26 v0.8.6

2022-11-02 12:22:43 v0.8.5

2022-08-14 13:53:23 v0.8.4

2022-07-26 07:40:48 v0.8.3

2022-05-26 14:58:20 v0.8.2

主题(topics):

chrome, chrome-debugging-protocol, chrome-devtools, golang, headless, testing, unit-testing

chromedp/chromedp同语言 Go最近更新仓库

2024-11-21 22:49:20 containerd/containerd

2024-11-21 13:50:50 XTLS/Xray-core

2024-11-21 07:36:18 kubernetes/kubernetes

2024-11-21 06:27:30 ollama/ollama

2024-11-21 05:17:55 Melkeydev/go-blueprint

2024-11-21 04:04:03 dolthub/dolt