browser

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2026 License: MIT Imports: 30 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BrowserPage

type BrowserPage struct {
	*rod.Page
	Browser *rod.Browser
	// contains filtered or unexported fields
}

BrowserPage is a combination of a browser and a page

func (*BrowserPage) CloseBrowserPage

func (b *BrowserPage) CloseBrowserPage()

func (*BrowserPage) FindNavigations

func (b *BrowserPage) FindNavigations() ([]*types.Action, error)

FindNavigation attempts to find more navigations on the page which could be done to find more links and pages.

This includes the following -

  1. Forms
  2. Buttons
  3. Links
  4. Elements with event listeners

The navigations found are unique across the page. The caller needs to ensure they are unique globally before doing further actions with details.

func (*BrowserPage) GetAllElements

func (b *BrowserPage) GetAllElements(selector string) ([]*types.HTMLElement, error)

func (*BrowserPage) GetAllForms

func (b *BrowserPage) GetAllForms() ([]*types.HTMLForm, error)

func (*BrowserPage) GetElementFromXpath

func (b *BrowserPage) GetElementFromXpath(xpath string) (*types.HTMLElement, error)

func (*BrowserPage) GetEventListeners

func (b *BrowserPage) GetEventListeners() ([]*types.EventListener, error)

GetEventListeners returns all event listeners on the page

func (b *BrowserPage) GetNavigatedLinks() ([]*NavigatedLink, error)

GetNavigatedLinks returns all navigated links on the page

func (*BrowserPage) WaitNewStable

func (p *BrowserPage) WaitNewStable(d time.Duration) error

WaitStable waits until the page is stable for d duration.

func (*BrowserPage) WaitPageLoadHeurisitics

func (b *BrowserPage) WaitPageLoadHeurisitics() error

WaitPageLoadHeurisitics waits for the page to load using multiple heuristics. Strategy order:

  1. Wait for initial load event (covers classic navigation & first paint).
  2. Poll for a URL change – the strongest signal on SPAs with client-side routing.
  3. If URL changes, wait a short grace period + network-idle window.
  4. If URL doesn't change, fall back to network-idle + DOM-stable windows.

This keeps fast pages fast while still succeeding on noisy, long-running SPAs.

func (*BrowserPage) WaitPageLoadHeuristicsFallback

func (b *BrowserPage) WaitPageLoadHeuristicsFallback() error

WaitPageLoadHeuristicsFallback provides the enhanced timeouts for complex navigation

type Launcher

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

Launcher is a high level controller to launch browsers and do the execution on them.

func NewLauncher

func NewLauncher(opts LauncherOptions) (*Launcher, error)

NewLauncher returns a new launcher instance

func (*Launcher) Close

func (l *Launcher) Close()

Close closes the launcher

func (*Launcher) GetPageFromPool

func (l *Launcher) GetPageFromPool() (*BrowserPage, error)

GetPageFromPool returns a page from the pool

func (*Launcher) PutBrowserToPool

func (l *Launcher) PutBrowserToPool(browser *BrowserPage)

func (*Launcher) ScopeValidator

func (l *Launcher) ScopeValidator() ScopeValidator

type LauncherOptions

type LauncherOptions struct {
	ChromiumPath        string
	MaxBrowsers         int
	PageMaxTimeout      time.Duration
	ShowBrowser         bool
	NoSandbox           bool
	Proxy               string
	SlowMotion          bool
	Trace               bool
	CookieConsentBypass bool
	ChromeUser          *user.User // optional chrome user to use

	ScopeValidator  ScopeValidator
	RequestCallback func(*output.Result)
}

LauncherOptions contains options for the launcher

type NavigatedLink struct {
	URL    string `json:"url"`
	Source string `json:"source"`
}

NavigatedLink is a link navigated collected from one of the navigation hooks.

type ScopeValidator

type ScopeValidator func(string) bool

type WaitOptions

type WaitOptions struct {
	URLPollInterval time.Duration // interval between successive URL polls
	URLPollTimeout  time.Duration // how long to keep polling before giving up on URL change
	PostChangeWait  time.Duration // small grace period after URL change for late requests
	IdleWait        time.Duration // network-idle window when no URL change happened
	DOMStableWait   time.Duration // DOM-stable window (used after idle)
	MaxTimeout      time.Duration // absolute upper bound for all waiting
}

WaitOptions controls how WaitPageLoadHeurisitics determines navigation completion. All durations are conservative defaults and can be tuned later via package-level variables or future setter methods (kept simple here to avoid breaking public API).

Directories

Path Synopsis
Package cookie implements cookie consent handling for the crawler.
Package cookie implements cookie consent handling for the crawler.
from stealth go-rod
from stealth go-rod

Jump to

Keyboard shortcuts

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