Yankun168 eae748aaa7 5.20BeforeSDK 11 tháng trước cách đây
..
device eae748aaa7 5.20BeforeSDK 11 tháng trước cách đây
js eae748aaa7 5.20BeforeSDK 11 tháng trước cách đây
kb eae748aaa7 5.20BeforeSDK 11 tháng trước cách đây
.gitignore eae748aaa7 5.20BeforeSDK 11 tháng trước cách đây
LICENSE eae748aaa7 5.20BeforeSDK 11 tháng trước cách đây
README.md eae748aaa7 5.20BeforeSDK 11 tháng trước cách đây
allocate.go eae748aaa7 5.20BeforeSDK 11 tháng trước cách đây
allocate_linux.go eae748aaa7 5.20BeforeSDK 11 tháng trước cách đây
allocate_other.go eae748aaa7 5.20BeforeSDK 11 tháng trước cách đây
browser.go eae748aaa7 5.20BeforeSDK 11 tháng trước cách đây
call.go eae748aaa7 5.20BeforeSDK 11 tháng trước cách đây
chromedp.go eae748aaa7 5.20BeforeSDK 11 tháng trước cách đây
conn.go eae748aaa7 5.20BeforeSDK 11 tháng trước cách đây
emulate.go eae748aaa7 5.20BeforeSDK 11 tháng trước cách đây
errors.go eae748aaa7 5.20BeforeSDK 11 tháng trước cách đây
eval.go eae748aaa7 5.20BeforeSDK 11 tháng trước cách đây
input.go eae748aaa7 5.20BeforeSDK 11 tháng trước cách đây
js.go eae748aaa7 5.20BeforeSDK 11 tháng trước cách đây
nav.go eae748aaa7 5.20BeforeSDK 11 tháng trước cách đây
poll.go eae748aaa7 5.20BeforeSDK 11 tháng trước cách đây
query.go eae748aaa7 5.20BeforeSDK 11 tháng trước cách đây
screenshot.go eae748aaa7 5.20BeforeSDK 11 tháng trước cách đây
target.go eae748aaa7 5.20BeforeSDK 11 tháng trước cách đây
util.go eae748aaa7 5.20BeforeSDK 11 tháng trước cách đây

README.md

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