Documentation
¶
Overview ¶
Package fetcher retrieves a URL once per agent profile.
Index ¶
- Constants
- type Fetcher
- func (f *Fetcher) Fetch(ctx context.Context, url string, profile types.Profile) types.FetchResult
- func (f *Fetcher) FetchAll(ctx context.Context, url string, profiles []types.Profile, concurrency int) []types.FetchResult
- func (f *Fetcher) Get(ctx context.Context, url, userAgent string, limit int64) (int, []byte, error)
- type Options
- type RequestSigner
- type TraceEvent
Constants ¶
View Source
const DefaultMaxBody = 5 << 20
DefaultMaxBody is the default response body cap (5 MiB).
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Fetcher ¶
type Fetcher struct {
// contains filtered or unexported fields
}
Fetcher fetches URLs once per profile. Browser profiles get a full Chrome impersonation (TLS, HTTP/2 settings and default headers); bot profiles get a plain client that only sends the profile's own headers, because real crawlers do not send Chrome client hints.
func (*Fetcher) Fetch ¶
Fetch retrieves url using profile. Network failures are reported in the result rather than returned, so one failing profile never aborts a run.
type Options ¶
type Options struct {
// Timeout bounds each request, including reading the body.
Timeout time.Duration
// Headers are added to every request after the profile headers.
Headers map[string]string
// MaxBody caps how many body bytes are read and kept. Zero means DefaultMaxBody.
MaxBody int64
// Retries is how many times a request is retried after a network error
// or a 502/504 gateway error. Other statuses are never retried because
// they are exactly what acurl reports on.
Retries int
// Proxy is an http, https or socks5 proxy URL.
Proxy string
// Insecure skips TLS certificate verification.
Insecure bool
// HTTPVersion forces "1.1" or "2". Empty negotiates as a browser would.
HTTPVersion string
// Method is the HTTP method for page requests. Empty means GET.
Method string
// BotTLS selects the TLS fingerprint for non-browser profiles: "go"
// (default, like most real crawlers) or "chrome" to make the user agent
// the only difference from the browser baseline.
BotTLS string
// Trace, if set, is called after every page request.
Trace func(TraceEvent)
// Signer, if set, signs every bot-profile request (Web Bot Auth).
Signer RequestSigner
// BlockPrivate refuses connections to private, loopback and other
// internal addresses (SSRF protection for acurl serve and mcp).
BlockPrivate bool
}
Options configures a Fetcher.
type RequestSigner ¶ added in v0.4.0
RequestSigner returns signature headers for a request.
Click to show internal directories.
Click to hide internal directories.