Documentation
¶
Overview ¶
Package browser provides a small wrapper around a shared, reusable headless Chromium instance (via go-rod). Loading pages through a real browser lets the media extractors bypass anti-bot challenges that block plain HTTP clients.
Index ¶
Constants ¶
const UserAgent = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36"
UserAgent is the desktop Chrome UA used for both navigation and any follow-up download requests that must look like they came from the same browser.
Variables ¶
var ErrClosed = errors.New("browser manager is closed")
ErrClosed is returned by Load/Warmup after the Manager has been closed.
Functions ¶
This section is empty.
Types ¶
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager owns a lazily-launched, reused browser instance.
func NewManager ¶
func NewManager() *Manager
NewManager creates a browser manager. The Chromium binary path can be set via BROWSER_BIN (recommended in containers); otherwise go-rod locates or downloads a browser.
func (*Manager) Close ¶
Close marks the Manager closed, waits for in-flight Load calls to finish, then shuts the shared browser down. Safe to call multiple times. After Close, Load and Warmup return ErrClosed instead of relaunching a new browser.
type Result ¶
type Result struct {
FinalURL string // URL after redirects
HTML string // full rendered HTML
Cookies []*proto.NetworkCookie // cookies set during the visit
}
Result is the outcome of loading a page.
func (*Result) CookieHeader ¶
CookieHeader renders the visit cookies into a Cookie request header value.