v0.3.3

API Reference

Last updated


The fetch and lifecycle functions of package browser, import path github.com/pardnchiu/go-browser/core, with an index of every exported symbol.

Fetch


  1. func Fetch(ctx context.Context, href string, timeout time.Duration, opt *Option) (*Result, error)

Loads href in Chrome and returns its content in the format chosen by opt.Type.
ParameterNotes
ctxCancels every wait in the call, including the semaphore and scroll delays
hrefMust have a scheme and a hostname containing ., otherwise invalid url
timeoutAbove 0, wraps ctx for each attempt's page load (not SameSession cookie extraction or browser launch); 0 or below means no extra deadline
optMay be nil; zero fields take defaults, see Option Fields

Picks headless or headed from opt and the runtime environment, and retries once headed only when the response is 403, 429 or 503 and the host has a GUI (Fetch Routing). Errors are either *Error with an HTTP-like status or a wrapped plain error (Troubleshooting). Safe to call from multiple goroutines; concurrency is capped by SetMaxConcurrency.

Close


  1. func Close()

Closes every cached browser instance and clears the cache. Safe to call more than once; later Fetch calls launch new instances.

SetMaxConcurrency


  1. func SetMaxConcurrency(n int)

Sets the cap on concurrent pages across all browsers, default 8. Does nothing when n <= 0. See Browser Cache.

Symbol index


SymbolKindPage
Fetch, Close, SetMaxConcurrencyfuncthis page
HTMLToMarkdown, HTMLToNode, Merge, DedupTree, DedupMarkdownParagraphs, InlineTimeElementsfuncContent Conversion
Option, Viewport, Result, Error, Node, BrowsertypeTypes
TypeMarkdown, TypeHTML, TypeJSON, DefaultUserAgent, ErrProfileNotFoundconst / varTypes

Symbols that existed in earlier releases are listed on Removed API.
中文