pkg

package
v0.0.0-...-98f70fd Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2025 License: LGPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BlankPage

func BlankPage(b *rod.Browser, url ...string) *rod.Page

Creates a blank webpage in a web browser.

func BuildSandboxless

func BuildSandboxless(opts BrowserOpts) (*rod.Browser, *launcher.Launcher, error)

Builds a browser without GPU acceleration or sandboxing. See: https://go-rod.github.io/#/custom-launch

func IsWhitelisted

func IsWhitelisted(host, path string, whitelists ...WhitelistEntry) bool

Checks if the given host and path are whitelisted.

func Page

func Page(b *rod.Browser, url ...string) (*rod.Page, error)

Creates a webpage in a browser using the same interface as `browser.MustPage()`, but without using `panic()`. Instead, an error is returned.

func PageJSON

func PageJSON(p *rod.Page) (string, error)

Gets a JSON string from a page returning `application/json`.

func PickRandDesktopDevice

func PickRandDesktopDevice() devices.Device

Gets a random desktop device for go-rod stealth.

func PickRandMobileDevice

func PickRandMobileDevice() devices.Device

Gets a random mobile device for go-rod stealth.

func RodFree

func RodFree(b *rod.Browser, l *launcher.Launcher)

Cleanup function for Rod browser and launcher.

func RodFreeManual

func RodFreeManual(b *rod.Browser, l *launcher.Launcher)

Cleanup function for Rod browser and launcher with manual cleanup of the data directory.

func SafeSelect

func SafeSelect(p *rod.Page, selector string) (*rod.Element, error)

Safely selects an element by its CSS selector using `p.Has()` This function doesn't halt when the element isn't found.

Types

type BrowserOpts

type BrowserOpts struct {
	Headless bool            //Whether to launch the browser without a GUI.
	Leakless bool            //Whether to automatically close the browser when the process exits.
	DevTools bool            //Whether to show the dev tools console; requires the browser to not be headless.
	Logger   io.Writer       //A generic writer to which logs should be sent.
	Ctx      context.Context //A context for the browser.
	GPU      bool            //Whether the GPU should be used.
}

Contains options for building the sandboxless browser.

func DefaultBrowserOpts

func DefaultBrowserOpts() BrowserOpts

Returns the default options for the sandboxless browser.

func DefaultBrowserOptsDbg

func DefaultBrowserOptsDbg() BrowserOpts

Returns the default options for the sandboxless browser when running manual tests.

func DefaultBrowserOptsWLogger

func DefaultBrowserOptsWLogger(l *log.Logger) BrowserOpts

Returns the default options for the sandboxless browser, with a logger. This logger is request independent and should be used for global debugging, not on a per-request basis.

type WhitelistEntry

type WhitelistEntry struct {
	Host  string
	Paths []string //If empty, all paths are allowed for that host
	Exts  []string //If empty, all extensions are allowed
}

WhitelistEntry represents a host with allowed paths.

Jump to

Keyboard shortcuts

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