Documentation
¶
Overview ¶
Package cloudfetch provides an HTTP client that bypasses Cloudflare bot detection by mimicking a real browser's TLS fingerprint and headers.
It uses uTLS to reproduce a browser's TLS Client Hello (JA3/JA4 fingerprint), sends that browser's default headers, and maintains a cookie jar across requests.
Index ¶
- Variables
- type Client
- func (c *Client) Cookies(rawURL string) []*http.Cookie
- func (c *Client) Do(method, rawURL string, body io.Reader) (*Response, error)
- func (c *Client) DoContext(ctx context.Context, method, rawURL string, body io.Reader) (*Response, error)
- func (c *Client) Get(rawURL string) (*Response, error)
- func (c *Client) Post(rawURL string, body io.Reader) (*Response, error)
- func (c *Client) Underlying() *http.Client
- type Option
- type Response
Constants ¶
This section is empty.
Variables ¶
var ( Chrome = utls.HelloChrome_Auto // Chrome 133 Firefox = utls.HelloFirefox_Auto // Firefox 120 Safari = utls.HelloSafari_Auto // Safari 16.0 Edge = utls.HelloEdge_Auto // Edge 85 )
ClientHelloID aliases for convenience. Each comes with request headers matching the same browser and version, so the TLS fingerprint and the User-Agent agree.
var MaxChallengeRetries = 3
MaxChallengeRetries is how many times to attempt solving a challenge.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is an HTTP client with browser TLS fingerprinting.
func (*Client) Do ¶
Do performs an HTTP request with the given method. If a Cloudflare challenge is detected, it attempts to solve it automatically.
func (*Client) DoContext ¶
func (c *Client) DoContext(ctx context.Context, method, rawURL string, body io.Reader) (*Response, error)
DoContext is like Do but honors ctx for every request and for the waits before submitting challenge answers. WithTimeout limits each HTTP request; give ctx a deadline to bound the whole call, including challenge solving.
func (*Client) Underlying ¶
Underlying returns the raw *http.Client for advanced use.
type Option ¶
type Option func(*Client)
Option configures a Client.
func WithBrowser ¶
func WithBrowser(id utls.ClientHelloID) Option
WithBrowser sets the browser to impersonate: its TLS fingerprint and its default headers. Defaults to Chrome. For a utls ClientHelloID other than the package presets, headers follow the preset for the same browser, so set User-Agent with WithHeader if the version differs.
func WithHeader ¶
WithHeader adds a default header sent with every request.
func WithProxy ¶
WithProxy routes connections through an HTTP proxy, given as "http://[user:pass@]host:port", using CONNECT tunnels. The TLS handshake with the target still happens end to end, so the fingerprint is unchanged.
func WithTimeout ¶
WithTimeout sets the HTTP client timeout. Defaults to 30s.