render

package
v1.0.0-beta.1 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2026 License: MIT Imports: 23 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package render provides the headless-rendering Fetcher backed by chromedp. It renders pages in a real Chromium tab, captures the post-JS DOM, records main-document redirects/status/headers via DevTools network events, and collects lab-mode Core Web Vitals (LCP, FCP, CLS, TBT, TTFB) using PerformanceObserver. On any rendering error the fetcher falls back to a raw HTTP fetch so a single broken page does not stall the crawl.

Headless mode requires a Chromium-class browser (Chrome, Chromium, or Edge) on PATH. NewHeadlessFetcher returns an error if no compatible browser can be launched.

Index

Constants

View Source
const LoginProfilePrefix = "gocrawl-login-"

LoginProfilePrefix is the temp-directory name prefix of a login window's throwaway browser profile; webserver.SweepStaleLoginProfiles recognizes leftovers by it.

Variables

View Source
var (
	// ErrNoBrowser means no Chromium-class browser is installed where gocrawl looks.
	ErrNoBrowser = errors.New("no Chromium-class browser found (install Google Chrome, Chromium or Microsoft Edge)")
	// ErrNoDisplay means a visible window can't open: no X11 or Wayland display.
	ErrNoDisplay = errors.New("no display for a browser window (DISPLAY and WAYLAND_DISPLAY are both unset)")
	// ErrLoginWindowClosed is returned by Cookies once the window is gone.
	ErrLoginWindowClosed = errors.New("the browser window was closed")
)

Functions

func FindBrowser

func FindBrowser() (string, error)

FindBrowser returns the path of the first Chromium-class browser it finds, or ErrNoBrowser.

func LoginAvailable

func LoginAvailable() error

LoginAvailable reports why OpenLoginWindow can't work on this machine, or nil when it can.

Types

type HeadlessFetcher

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

HeadlessFetcher renders pages with chromedp and reports real Core Web Vitals.

func NewHeadlessFetcher

func NewHeadlessFetcher(opts crawler.Options) (*HeadlessFetcher, error)

NewHeadlessFetcher launches the headless browser. It returns an error if no Chromium binary is available on PATH or the browser fails to start. Callers must Close() the fetcher when finished.

func (*HeadlessFetcher) Close

func (h *HeadlessFetcher) Close() error

Close terminates the browser. Safe to call more than once.

func (*HeadlessFetcher) Fetch

func (h *HeadlessFetcher) Fetch(ctx context.Context, rawURL string) (*crawler.Page, error)

Fetch renders rawURL in a fresh tab. On rendering failure it falls back to a raw HTTP fetch and annotates the page's RenderResult with the failure reason.

type LoginWindow

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

LoginWindow is a browser window opened for a person to log in to a site by hand, in a throwaway profile directory that Close deletes. gocrawl only reads its cookie jar.

func OpenLoginWindow

func OpenLoginWindow(ctx context.Context, rawURL string) (*LoginWindow, error)

OpenLoginWindow starts a visible browser on rawURL. ctx bounds only the launch and the first navigation: the window stays open until Close, the person closes it, or the process exits.

func (*LoginWindow) Close

func (w *LoginWindow) Close() error

Close stops the browser and deletes the throwaway profile. Safe to call more than once.

func (*LoginWindow) Cookies

func (w *LoginWindow) Cookies(ctx context.Context) ([]*http.Cookie, error)

Cookies reads the browser's whole cookie jar over CDP, HttpOnly cookies and values included. Filtering to the site is the caller's job.

func (*LoginWindow) Done

func (w *LoginWindow) Done() <-chan struct{}

Done is closed once the window is gone, by Close or by the person.

Jump to

Keyboard shortcuts

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