Documentation
¶
Index ¶
- func BlankPage(b *rod.Browser, url ...string) *rod.Page
- func BuildSandboxless(opts BrowserOpts) (*rod.Browser, *launcher.Launcher, error)
- func IsWhitelisted(host, path string, whitelists ...WhitelistEntry) bool
- func Page(b *rod.Browser, url ...string) (*rod.Page, error)
- func PageJSON(p *rod.Page) (string, error)
- func PickRandDesktopDevice() devices.Device
- func PickRandMobileDevice() devices.Device
- func RodFree(b *rod.Browser, l *launcher.Launcher)
- func RodFreeManual(b *rod.Browser, l *launcher.Launcher)
- func SafeSelect(p *rod.Page, selector string) (*rod.Element, error)
- type BrowserOpts
- type WhitelistEntry
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildSandboxless ¶
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 ¶
Creates a webpage in a browser using the same interface as `browser.MustPage()`, but without using `panic()`. Instead, an error is returned.
func PickRandDesktopDevice ¶
Gets a random desktop device for go-rod stealth.
func PickRandMobileDevice ¶
Gets a random mobile device for go-rod stealth.
func RodFreeManual ¶
Cleanup function for Rod browser and launcher with manual cleanup of the data directory.
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.