browser

package
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 14, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package browser drives a real headless Chrome through the DevTools Protocol so JavaScript-built pages are captured as they actually render. kage always goes through here: navigate, let the page settle, then serialise the final DOM — the same markup a human would have seen — which the rest of the pipeline then strips of scripts and localises.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LookChrome

func LookChrome() (string, bool)

LookChrome reports the path of a usable Chrome/Chromium binary and whether one was found, checking KAGE_CHROME, CHROME_BIN, rod's own lookup, and the common system install locations. Tests use it to skip when no browser is present.

Types

type Options

type Options struct {
	Headless      bool          // run Chrome without a window
	Workers       int           // max concurrent pages
	Settle        time.Duration // network-idle quiet period after load
	RenderTimeout time.Duration // hard cap per page render
	Scroll        bool          // auto-scroll to trigger lazy-loaded media
	ChromeBin     string        // explicit binary; empty = autodetect
	ControlURL    string        // attach to an existing Chrome instead of launching
}

Options configure a Pool.

func DefaultOptions

func DefaultOptions() Options

DefaultOptions returns the baseline render settings.

type Pool

type Pool struct {
	// contains filtered or unexported fields
}

Pool owns one Chrome process shared across a run and bounds the number of pages open at once.

func New

func New(opts Options) *Pool

New creates a Pool. Chrome is launched lazily on the first Render.

func (*Pool) Close

func (p *Pool) Close() error

Close shuts down the managed Chrome process.

func (*Pool) Render

func (p *Pool) Render(ctx context.Context, rawURL string) (RenderResult, error)

Render navigates to rawURL, lets it settle, and returns the final rendered HTML. It acquires a page slot from the pool and releases it when done.

type RenderResult

type RenderResult struct {
	HTML     string // the serialised final DOM
	FinalURL string // URL after any client-side redirects
	Title    string
}

RenderResult is the outcome of rendering one page.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL