Documentation
¶
Overview ¶
Package chrome starts a headed Chrome and connects to it over the DevTools protocol, the way a page behind a bot check needs it driven.
The DevTools port is chosen here and given to Chrome by number: a Chrome told port 0, or driven over --remote-debugging-pipe, declares itself automated to every page (navigator.webdriver is true), and Cloudflare's Turnstile then never passes. Headless is refused outright, so Chrome needs a display, Xvfb in a container.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var DefaultFlags = []string{
"--no-first-run",
"--no-default-browser-check",
"--no-sandbox",
"--disable-dev-shm-usage",
"--password-store=basic",
"--window-size=1280,720",
"--disable-background-networking",
}
DefaultFlags are what Chrome is started with besides the profile and the port. The sandbox needs namespaces a container does not give, and /dev/shm in a container is too small for Chrome's shared memory.
var ErrChromeExited = errors.New("chrome exited")
ErrChromeExited is Chrome gone before it listened.
Functions ¶
func DevToolsEndpoint ¶
DevToolsEndpoint waits for Chrome to listen on its port and returns the browser's own endpoint there, from the version it reports. With a fixed port Chrome writes no DevToolsActivePort file to read it from instead.
Types ¶
type Browser ¶
Browser is a running Chrome and the connection to it.
func Launch ¶
func Launch(ctx context.Context, chromePath string, profileDirectory string, flags ...string) (*Browser, error)
Launch starts Chrome on the profile directory with DefaultFlags and the flags given, and connects to it. Chrome is killed, with every process it started, when the context ends; Close ends it sooner, and more gently.