Documentation
¶
Overview ¶
Package browse provides a Gin-like API for browser automation using pure CDP over WebSocket.
browse-go applies Gin's middleware/context/group patterns to browser automation, giving Go developers a familiar, composable way to script browser interactions.
engine := browse.Default(browse.WithHeadless(true))
engine.MustLaunch()
defer engine.Close()
engine.Task("search", func(c *browse.Context) {
c.MustNavigate("https://example.com")
c.El("input[name=q]").MustInput("hello")
c.El("button[type=submit]").MustClick()
})
engine.Run("search")
Index ¶
- Constants
- Variables
- func NewTaskLifecycle(taskName string) (*statekit.MachineConfig[TaskLifecycleContext], error)
- func SetLogger(l *bolt.Logger)
- type Browser
- type BulkheadFullError
- type CircuitOpenError
- type ClipRegion
- type Context
- func (c *Context) Abort()
- func (c *Context) AbortWithError(err error)
- func (c *Context) Cookies() ([]Cookie, error)
- func (c *Context) El(selector string) *Selection
- func (c *Context) ElAll(selector string) *SelectionAll
- func (c *Context) Errors() []error
- func (c *Context) Eval(js string) (any, error)
- func (c *Context) ExtractTable(tableSelector string) (*Table, error)
- func (c *Context) FillForm(fields map[string]string) error
- func (c *Context) Get(key string) (any, bool)
- func (c *Context) GetString(key string) string
- func (c *Context) GoContext() context.Context
- func (c *Context) HTML() (string, error)
- func (c *Context) HasEl(selector string) bool
- func (c *Context) IsAborted() bool
- func (c *Context) MustNavigate(url string) *Context
- func (c *Context) Navigate(url string) error
- func (c *Context) Next()
- func (c *Context) PDF() ([]byte, error)
- func (c *Context) PDFTo(path string) error
- func (c *Context) Page() *Page
- func (c *Context) RestoreIndex(idx int)
- func (c *Context) SaveIndex() int
- func (c *Context) Screenshot() ([]byte, error)
- func (c *Context) ScreenshotElement(selector string) ([]byte, error)
- func (c *Context) ScreenshotFullPage() ([]byte, error)
- func (c *Context) ScreenshotTo(path string) error
- func (c *Context) Set(key string, value any)
- func (c *Context) SetCookie(cookie Cookie) error
- func (c *Context) StartRecording(opts RecorderOptions) (*Recorder, error)
- func (c *Context) TaskName() string
- func (c *Context) URL() string
- func (c *Context) WaitLoad() error
- func (c *Context) WaitNavigation() error
- func (c *Context) WaitSelector(selector string) error
- func (c *Context) WaitStable() error
- type Cookie
- type ElementNotFoundError
- type Engine
- func (e *Engine) Close() error
- func (e *Engine) ExistingPage() (*Page, error)
- func (e *Engine) Group(name string, middleware ...HandlerFunc) *Group
- func (e *Engine) Launch() error
- func (e *Engine) MustLaunch() *Engine
- func (e *Engine) NewPage() (*Page, error)
- func (e *Engine) NewPageAt(url string) (*Page, error)
- func (e *Engine) Run(taskName string) error
- func (e *Engine) RunAll() error
- func (e *Engine) RunGroup(groupName string) error
- func (e *Engine) Task(name string, handlers ...HandlerFunc)
- func (e *Engine) Use(middleware ...HandlerFunc)
- type Group
- type HandlerFunc
- type HandlersChain
- type NavigationError
- type Option
- func WithAllowPrivateIPs(allow bool) Option
- func WithHeadless(h bool) Option
- func WithPoolSize(n int) Option
- func WithProxy(proxy string) Option
- func WithRemoteCDP(wsURL string) Option
- func WithSlowMotion(d time.Duration) Option
- func WithTimeout(d time.Duration) Option
- func WithUserAgent(ua string) Option
- func WithViewport(width, height int) Option
- type PDFOptions
- type Page
- func (p *Page) Call(method string, params any) (json.RawMessage, error)
- func (p *Page) Close() error
- func (p *Page) Cookies() ([]Cookie, error)
- func (p *Page) Evaluate(expression string) (any, error)
- func (p *Page) HTML() (string, error)
- func (p *Page) Navigate(rawURL string) error
- func (p *Page) OnSession(method string, handler func(params map[string]any)) func()
- func (p *Page) PDF() ([]byte, error)
- func (p *Page) PDFWithOptions(opts PDFOptions) ([]byte, error)
- func (p *Page) QuerySelector(selector string) (int64, error)
- func (p *Page) QuerySelectorAll(selector string) ([]int64, error)
- func (p *Page) QuerySelectorPiercing(selector string) (int64, error)
- func (p *Page) ResolveNode(nodeID int64) (string, error)
- func (p *Page) Screenshot() ([]byte, error)
- func (p *Page) ScreenshotCompact() ([]byte, error)
- func (p *Page) ScreenshotElement(nodeID int64) ([]byte, error)
- func (p *Page) ScreenshotFullPage() ([]byte, error)
- func (p *Page) ScreenshotWithOptions(opts ScreenshotOptions) ([]byte, error)
- func (p *Page) SetCookie(c Cookie) error
- func (p *Page) SetUserAgent(ua string) error
- func (p *Page) SetViewport(width, height int) error
- func (p *Page) URL() (string, error)
- func (p *Page) WaitForSelector(selector string) error
- func (p *Page) WaitLoad() error
- func (p *Page) WaitStable(d time.Duration) error
- type RateLimitError
- type Recorder
- func (r *Recorder) Cleanup() error
- func (r *Recorder) FrameCount() int64
- func (r *Recorder) Frames() ([]string, error)
- func (r *Recorder) FramesDir() string
- func (r *Recorder) SaveGIF(outputPath string, fps int) error
- func (r *Recorder) SaveVideo(outputPath string, fps int) error
- func (r *Recorder) Start() error
- func (r *Recorder) Stop() error
- type RecorderOptions
- type ScreenshotOptions
- type Selection
- func (s *Selection) Attr(name string) (string, error)
- func (s *Selection) Clear() error
- func (s *Selection) Click() error
- func (s *Selection) Err() error
- func (s *Selection) Hover() error
- func (s *Selection) Input(text string) error
- func (s *Selection) MustClick() *Selection
- func (s *Selection) MustInput(text string) *Selection
- func (s *Selection) MustText() string
- func (s *Selection) Screenshot() ([]byte, error)
- func (s *Selection) Text() (string, error)
- func (s *Selection) Value() (string, error)
- func (s *Selection) Visible() (bool, error)
- func (s *Selection) WaitEnabled() *Selection
- func (s *Selection) WaitStable() *Selection
- func (s *Selection) WaitVisible() *Selection
- type SelectionAll
- func (sa *SelectionAll) At(i int) *Selection
- func (sa *SelectionAll) Count() int
- func (sa *SelectionAll) Each(fn func(int, *Selection)) error
- func (sa *SelectionAll) Filter(fn func(*Selection) bool) *SelectionAll
- func (sa *SelectionAll) First() *Selection
- func (sa *SelectionAll) Last() *Selection
- func (sa *SelectionAll) Texts() ([]string, error)
- type Table
- type TaskLifecycleContext
- type TaskTracker
- func (t *TaskTracker) Abort()
- func (t *TaskTracker) Context() TaskLifecycleContext
- func (t *TaskTracker) Fail(err error)
- func (t *TaskTracker) IsDone() bool
- func (t *TaskTracker) Matches(state statekit.StateID) bool
- func (t *TaskTracker) Reset()
- func (t *TaskTracker) Retry()
- func (t *TaskTracker) Start()
- func (t *TaskTracker) State() statekit.StateID
- func (t *TaskTracker) Stop()
- func (t *TaskTracker) Success()
- type TimeoutError
- type URLValidator
Constants ¶
const ( EventStart statekit.EventType = "START" EventSuccess statekit.EventType = "SUCCESS" EventFail statekit.EventType = "FAIL" EventRetry statekit.EventType = "RETRY" EventAbort statekit.EventType = "ABORT" EventReset statekit.EventType = "RESET" )
Task lifecycle events
const ( StatePending statekit.StateID = "pending" StateRunning statekit.StateID = "running" StateSuccess statekit.StateID = "success" StateFailed statekit.StateID = "failed" StateAborted statekit.StateID = "aborted" StateRetrying statekit.StateID = "retrying" )
Task lifecycle states
Variables ¶
var DefaultURLValidator = URLValidator{AllowPrivateIPs: false}
DefaultURLValidator blocks private IPs and non-http(s) schemes.
Functions ¶
func NewTaskLifecycle ¶
func NewTaskLifecycle(taskName string) (*statekit.MachineConfig[TaskLifecycleContext], error)
NewTaskLifecycle creates a statekit machine modeling the task execution lifecycle.
pending → START → running running → SUCCESS → success (final) running → FAIL → failed (final) running → ABORT → aborted (final) running → RETRY → retrying retrying → START → running failed → RESET → pending
Types ¶
type Browser ¶
type Browser interface {
NewPage() (*Page, error)
NewPageAt(url string) (*Page, error)
ExistingPage() (*Page, error)
Close() error
}
Browser is the interface for browser lifecycle management. Engine implements this. The agent package depends on this interface rather than on *Engine directly, enabling testing without a real browser.
type BulkheadFullError ¶
type BulkheadFullError struct {
TaskName string
}
BulkheadFullError is returned when the bulkhead is at capacity.
func (*BulkheadFullError) Error ¶
func (e *BulkheadFullError) Error() string
type CircuitOpenError ¶
type CircuitOpenError struct {
TaskName string
}
CircuitOpenError is returned when the circuit breaker is open.
func (*CircuitOpenError) Error ¶
func (e *CircuitOpenError) Error() string
type ClipRegion ¶
type ClipRegion struct {
X, Y, Width, Height float64
}
ClipRegion defines a rectangular area for screenshot clipping.
type Context ¶
type Context struct {
// contains filtered or unexported fields
}
Context carries the page state, middleware chain, and data for a single task execution.
func NewTestContext ¶
func NewTestContext(taskName string, handlers HandlersChain) *Context
NewTestContext creates a Context without a page for testing middleware chains.
func (*Context) AbortWithError ¶
AbortWithError stops the chain and records an error.
func (*Context) ElAll ¶
func (c *Context) ElAll(selector string) *SelectionAll
ElAll returns a SelectionAll for all elements matching the CSS selector.
func (*Context) ExtractTable ¶
ExtractTable extracts data from an HTML table element. It reads <th> cells for headers and <td> cells for row data.
func (*Context) FillForm ¶
FillForm fills multiple form fields at once. The map keys are CSS selectors, values are the text to input.
func (*Context) GoContext ¶
GoContext returns the underlying context.Context for cancellation propagation. Use this in middleware that wraps fortify or other context-aware libraries.
func (*Context) MustNavigate ¶
MustNavigate calls Navigate and panics on error.
func (*Context) Next ¶
func (c *Context) Next()
Next calls the next handler in the middleware chain.
func (*Context) RestoreIndex ¶
RestoreIndex resets the handler chain position for re-execution. Used by resilience middleware to replay the downstream handler chain.
func (*Context) SaveIndex ¶
SaveIndex returns the current handler index so it can be restored for retry. Used by resilience middleware (retry, timeout, circuit breaker, bulkhead).
func (*Context) Screenshot ¶
Screenshot captures the full page as PNG bytes.
func (*Context) ScreenshotElement ¶
ScreenshotElement captures a screenshot of a single element.
func (*Context) ScreenshotFullPage ¶
ScreenshotFullPage captures the entire scrollable page as PNG bytes.
func (*Context) ScreenshotTo ¶
ScreenshotTo captures a screenshot and writes it to the given file path.
func (*Context) StartRecording ¶
func (c *Context) StartRecording(opts RecorderOptions) (*Recorder, error)
StartRecording begins capturing screencast frames for video. Returns a Recorder that must be stopped and saved.
func (*Context) WaitNavigation ¶
WaitNavigation waits for a navigation to complete after performing an action. Call this after clicking a link that triggers a page load.
func (*Context) WaitSelector ¶
WaitSelector waits until an element matching the selector appears in the DOM.
func (*Context) WaitStable ¶
WaitStable waits until the page DOM is stable.
type Cookie ¶
type Cookie struct {
Name string `json:"name"`
Value string `json:"value"`
Domain string `json:"domain,omitempty"`
Path string `json:"path,omitempty"`
Expires float64 `json:"expires,omitempty"`
Secure bool `json:"secure,omitempty"`
HTTPOnly bool `json:"httpOnly,omitempty"`
SameSite string `json:"sameSite,omitempty"`
}
Cookie represents a browser cookie.
type ElementNotFoundError ¶
type ElementNotFoundError struct {
Selector string
}
ElementNotFoundError is returned when a selector matches no elements.
func (*ElementNotFoundError) Error ¶
func (e *ElementNotFoundError) Error() string
type Engine ¶
type Engine struct {
// contains filtered or unexported fields
}
Engine manages the browser lifecycle, global middleware, and task registry.
func (*Engine) ExistingPage ¶ added in v1.2.1
ExistingPage attaches to an existing browser page (e.g. the initial about:blank tab). Returns nil if no existing page target is found.
func (*Engine) Group ¶
func (e *Engine) Group(name string, middleware ...HandlerFunc) *Group
Group creates a named group with optional middleware.
func (*Engine) Launch ¶
Launch starts the browser or connects to a remote CDP endpoint. If WithRemoteCDP was set, connects to the remote WebSocket URL instead of launching Chrome.
func (*Engine) MustLaunch ¶
MustLaunch calls Launch and panics on error.
func (*Engine) NewPageAt ¶ added in v0.9.1
NewPageAt creates a new browser page/tab and navigates directly to the URL. Faster than NewPage + Navigate because Chrome loads the URL during target creation.
func (*Engine) RunAll ¶
RunAll executes all registered tasks (root and groups). When WithPoolSize is set, tasks run concurrently up to the pool limit. Otherwise, tasks run sequentially.
func (*Engine) Task ¶
func (e *Engine) Task(name string, handlers ...HandlerFunc)
Task registers a named task with handlers on the engine (root group).
func (*Engine) Use ¶
func (e *Engine) Use(middleware ...HandlerFunc)
Use appends global middleware to the engine.
type Group ¶
type Group struct {
// contains filtered or unexported fields
}
Group represents a named collection of tasks with shared middleware.
func (*Group) Group ¶
func (g *Group) Group(name string, middleware ...HandlerFunc) *Group
Group creates a sub-group that inherits this group's middleware.
func (*Group) Task ¶
func (g *Group) Task(name string, handlers ...HandlerFunc)
Task registers a named task within this group. The final handler chain is: engine middleware + group middleware + task handlers.
func (*Group) Use ¶
func (g *Group) Use(middleware ...HandlerFunc)
Use appends middleware to this group. Group middleware runs after engine middleware.
type HandlerFunc ¶
type HandlerFunc func(*Context)
HandlerFunc defines the handler function signature for middleware and tasks.
func Logger ¶
func Logger() HandlerFunc
Logger returns middleware that logs task execution using bolt.
func Recovery ¶
func Recovery() HandlerFunc
Recovery returns middleware that recovers from panics and records the error.
type HandlersChain ¶
type HandlersChain []HandlerFunc
HandlersChain is a slice of HandlerFunc used to build middleware chains.
type NavigationError ¶
type NavigationError struct {
}
NavigationError is returned when page navigation fails.
func (*NavigationError) Error ¶
func (e *NavigationError) Error() string
func (*NavigationError) Unwrap ¶
func (e *NavigationError) Unwrap() error
type Option ¶
type Option func(*options)
Option configures an Engine.
func WithAllowPrivateIPs ¶
WithAllowPrivateIPs permits navigation to private/loopback IP addresses. By default, navigation to private IPs is blocked to prevent SSRF. Enable for testing or internal network automation.
func WithHeadless ¶
WithHeadless sets whether the browser runs in headless mode.
func WithPoolSize ¶
WithPoolSize sets the number of reusable pages in the page pool. When > 0, RunAll executes tasks concurrently up to this limit. Default 0 means sequential execution with no pooling.
func WithProxy ¶
WithProxy routes browser traffic through the specified proxy server. Format: "http://host:port" or "socks5://host:port".
func WithRemoteCDP ¶
WithRemoteCDP connects to an already-running Chrome instance via WebSocket URL instead of launching a local browser. Use with Browserbase, Steel, or self-hosted Chrome.
engine := browse.New(browse.WithRemoteCDP("ws://localhost:9222/devtools/browser/..."))
func WithSlowMotion ¶
WithSlowMotion adds artificial delay between actions.
func WithTimeout ¶
WithTimeout sets the default timeout for browser operations.
func WithUserAgent ¶
WithUserAgent sets a custom User-Agent string for all pages.
func WithViewport ¶
WithViewport sets the browser viewport dimensions.
type PDFOptions ¶
type PDFOptions struct {
Landscape bool
PrintBackground bool
Scale float64
PaperWidth float64 // inches, default 8.5
PaperHeight float64 // inches, default 11
MarginTop float64 // inches, default 0.4
MarginBottom float64 // inches, default 0.4
MarginLeft float64 // inches, default 0.4
MarginRight float64 // inches, default 0.4
PageRanges string // e.g. "1-5", "1,3,5-7"
}
PDFOptions configures PDF generation.
type Page ¶
type Page struct {
// contains filtered or unexported fields
}
Page wraps a CDP session for a single browser tab.
func (*Page) Call ¶
Call sends a raw CDP command scoped to this page's session. This is an escape hatch for advanced CDP operations not covered by the Page API.
func (*Page) Navigate ¶
Navigate loads the given URL and waits for the page to finish loading. Only http:// and https:// URLs are allowed. Private IPs are blocked by default.
func (*Page) OnSession ¶
OnSession registers an event handler scoped to this page's session. Events from other pages/sessions are filtered out. Returns an unsubscribe function to remove the handler.
func (*Page) PDFWithOptions ¶
func (p *Page) PDFWithOptions(opts PDFOptions) ([]byte, error)
PDFWithOptions generates a PDF with the given options.
func (*Page) QuerySelector ¶
QuerySelector finds the first element matching the CSS selector and returns its node ID.
func (*Page) QuerySelectorAll ¶
QuerySelectorAll finds all elements matching the CSS selector.
func (*Page) QuerySelectorPiercing ¶ added in v0.5.0
QuerySelectorPiercing finds the first element matching the selector, piercing through shadow DOM boundaries. Uses DOM.getFlattenedDocument with pierce:true for a single-call flattened DOM traversal, falling back to JS-based search if the flattened approach finds no match.
func (*Page) ResolveNode ¶
ResolveNode resolves a DOM nodeId to a Runtime remote object ID.
func (*Page) Screenshot ¶
Screenshot captures the page as a PNG image (viewport only, no size limit).
func (*Page) ScreenshotCompact ¶
ScreenshotCompact captures the page with a 5MB size limit. Automatically switches to JPEG and downscales if needed. Use this for LLM/agent contexts where size matters.
func (*Page) ScreenshotElement ¶
ScreenshotElement captures a screenshot of a specific element by its node ID.
func (*Page) ScreenshotFullPage ¶
ScreenshotFullPage captures the entire scrollable page as a PNG image.
func (*Page) ScreenshotWithOptions ¶
func (p *Page) ScreenshotWithOptions(opts ScreenshotOptions) ([]byte, error)
ScreenshotWithOptions captures the page with the given options. If MaxSize is set and the result exceeds it, the image is automatically re-captured with progressive quality/resolution reduction.
func (*Page) SetUserAgent ¶
SetUserAgent sets the user agent string for this page.
func (*Page) SetViewport ¶
SetViewport sets the page viewport dimensions.
func (*Page) WaitForSelector ¶
WaitForSelector waits until an element matching the selector exists in the DOM.
type RateLimitError ¶
type RateLimitError struct {
TaskName string
}
RateLimitError is returned when a task is rejected by the rate limiter.
func (*RateLimitError) Error ¶
func (e *RateLimitError) Error() string
type Recorder ¶
type Recorder struct {
// contains filtered or unexported fields
}
Recorder captures screencast frames from a page and assembles them into a video.
func NewRecorder ¶
func NewRecorder(page *Page, opts RecorderOptions) (*Recorder, error)
NewRecorder creates a recorder for the given page. Frames are saved to a temporary directory until Stop is called.
func (*Recorder) FrameCount ¶
FrameCount returns the number of frames captured so far.
type RecorderOptions ¶
type RecorderOptions struct {
// Format is "jpeg" (default, smaller) or "png" (lossless).
Format string
// Quality is JPEG quality 1-100. Default 80.
Quality int
// MaxWidth limits the frame width. 0 means no limit.
MaxWidth int
// MaxHeight limits the frame height. 0 means no limit.
MaxHeight int
}
RecorderOptions configures video recording.
type ScreenshotOptions ¶
type ScreenshotOptions struct {
// Format is "png" (default) or "jpeg".
Format string
// Quality is JPEG quality 1-100. Ignored for PNG.
Quality int
// FullPage captures the entire scrollable page, not just the viewport.
FullPage bool
// Clip captures a specific region of the page.
Clip *ClipRegion
// MaxSize is the maximum allowed size in bytes. If the screenshot exceeds
// this limit, it is automatically re-captured as JPEG with progressively
// lower quality and downscaled resolution until it fits.
// 0 means no limit. Recommended: 5*1024*1024 (5MB) for LLM contexts.
MaxSize int
// MaxWidth downscales the capture to this width if set. Height scales proportionally.
// Applied via CDP's clip.scale parameter. 0 means no downscaling.
MaxWidth int
}
ScreenshotOptions configures screenshot capture.
type Selection ¶
type Selection struct {
// contains filtered or unexported fields
}
Selection wraps a single page element with a fluent, chainable API.
func NewSelection ¶
NewSelection creates a Selection for the given page and node ID.
func (*Selection) Screenshot ¶
Screenshot captures a screenshot of this element only.
func (*Selection) WaitEnabled ¶
WaitEnabled waits until the element is enabled.
func (*Selection) WaitStable ¶
WaitStable waits until the element's position is stable.
func (*Selection) WaitVisible ¶
WaitVisible waits until the element is visible.
type SelectionAll ¶
type SelectionAll struct {
// contains filtered or unexported fields
}
SelectionAll wraps multiple elements for batch operations.
func (*SelectionAll) At ¶
func (sa *SelectionAll) At(i int) *Selection
At returns the element at the given index.
func (*SelectionAll) Count ¶
func (sa *SelectionAll) Count() int
Count returns the number of matched elements.
func (*SelectionAll) Each ¶
func (sa *SelectionAll) Each(fn func(int, *Selection)) error
Each iterates over each matched element with its index.
func (*SelectionAll) Filter ¶
func (sa *SelectionAll) Filter(fn func(*Selection) bool) *SelectionAll
Filter returns a new SelectionAll containing only elements that pass the predicate.
func (*SelectionAll) First ¶
func (sa *SelectionAll) First() *Selection
First returns the first matched element.
func (*SelectionAll) Last ¶
func (sa *SelectionAll) Last() *Selection
Last returns the last matched element.
func (*SelectionAll) Texts ¶
func (sa *SelectionAll) Texts() ([]string, error)
Texts returns the text content of all matched elements.
type TaskLifecycleContext ¶
TaskLifecycleContext holds the context for a task's state machine.
type TaskTracker ¶
type TaskTracker struct {
// contains filtered or unexported fields
}
TaskTracker wraps a statekit Interpreter to track task execution state.
func NewTaskTracker ¶
func NewTaskTracker(taskName string) (*TaskTracker, error)
NewTaskTracker creates a tracker for the given task name.
func (*TaskTracker) Abort ¶
func (t *TaskTracker) Abort()
Abort transitions the task to aborted state.
func (*TaskTracker) Context ¶
func (t *TaskTracker) Context() TaskLifecycleContext
Context returns the current task lifecycle context.
func (*TaskTracker) Fail ¶
func (t *TaskTracker) Fail(err error)
Fail transitions the task to failed state with an error.
func (*TaskTracker) IsDone ¶
func (t *TaskTracker) IsDone() bool
IsDone returns true if the task is in a terminal state.
func (*TaskTracker) Matches ¶
func (t *TaskTracker) Matches(state statekit.StateID) bool
Matches checks if the task is in the given state.
func (*TaskTracker) Reset ¶
func (t *TaskTracker) Reset()
Reset transitions a failed task back to pending.
func (*TaskTracker) Retry ¶
func (t *TaskTracker) Retry()
Retry transitions the task to retrying state.
func (*TaskTracker) Start ¶
func (t *TaskTracker) Start()
Start transitions the task to running state.
func (*TaskTracker) State ¶
func (t *TaskTracker) State() statekit.StateID
State returns the current state ID.
func (*TaskTracker) Success ¶
func (t *TaskTracker) Success()
Success transitions the task to success state.
type TimeoutError ¶
TimeoutError is returned when an operation exceeds its deadline.
func (*TimeoutError) Error ¶
func (e *TimeoutError) Error() string
type URLValidator ¶
type URLValidator struct {
AllowPrivateIPs bool
}
URLValidator controls URL validation for navigation. Set AllowPrivateIPs to true to permit loopback/private IP navigation (e.g., for testing).
func (URLValidator) Validate ¶
func (v URLValidator) Validate(rawURL string) error
Validate checks that a URL is safe for navigation. Blocks non-http(s) schemes and private/loopback IPs (unless AllowPrivateIPs is set).
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package agent provides a high-level, agent-optimized API for browser automation.
|
Package agent provides a high-level, agent-optimized API for browser automation. |
|
cmd
|
|
|
scout
command
scout is the CLI for AI-powered browser automation.
|
scout is the CLI for AI-powered browser automation. |
|
examples
|
|
|
demo
command
Example: demo showcases browse-go's middleware, groups, and task composition.
|
Example: demo showcases browse-go's middleware, groups, and task composition. |
|
login
command
Example: login demonstrates authenticating to a web application.
|
Example: login demonstrates authenticating to a web application. |
|
scrape
command
Example: scrape demonstrates extracting structured data from a web page.
|
Example: scrape demonstrates extracting structured data from a web page. |
|
internal
|
|
|
agui
Package agui implements an AG-UI protocol server for scout browser automation.
|
Package agui implements an AG-UI protocol server for scout browser automation. |
|
cdp
Package cdp provides a low-level Chrome DevTools Protocol client over WebSocket.
|
Package cdp provides a low-level Chrome DevTools Protocol client over WebSocket. |
|
launcher
Package launcher finds and starts a Chrome/Chromium process.
|
Package launcher finds and starts a Chrome/Chromium process. |
|
wait
Package wait provides context-aware auto-wait utilities for page readiness.
|
Package wait provides context-aware auto-wait utilities for page readiness. |
|
Package middleware provides reusable middleware for browse-go tasks.
|
Package middleware provides reusable middleware for browse-go tasks. |