Pavel-R / chromedp

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

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

About chromedp GoDoc Build Status

Package chromedp is a faster, simpler way to drive browsers supporting the Chrome DevTools Protocol in Go using the 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. The examples repository contains more complex scenarios.

Frequently Asked Questions

I can't see any Chrome browser window

By default, it's run in headless mode. See DefaultExecAllocatorOptions, and an example to override said options.

I'm seeing "context canceled" errors

If the connection to the browser is dropped, the context will be cancelled, which can be an unexpected reason for this error. For example, if the browser is closed manually.

Chrome exits as soon as my Go program finishes

This is set up on Linux to avoid leaking resources. If you want Chrome to be a long-running process, start it separately and connect to it via RemoteAllocator.

Execute an action results in "invalid context"

By default, a chromedp context doesn't have an executor set up. You can specify one; see #326.

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
}))

Resources

About

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

License:MIT License


Languages

Language:Go 100.0%