cloudscraper

package
v0.0.0-...-9c02708 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 10, 2025 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Options

type Options struct {
	MaxRetries             int
	Delay                  time.Duration
	AutoRefreshOn403       bool
	SessionRefreshInterval time.Duration
	Max403Retries          int
	Browser                useragent.Config
	RotateTlsCiphers       bool
	CaptchaSolver          captcha.Solver
	Proxies                []string
	ProxyOptions           struct {
		Strategy proxy.Strategy
		BanTime  time.Duration
	}
	Stealth        stealth.Options
	JSRuntime      js.Runtime // "goja", "node", "deno", "bun"
	CustomJSEngine js.Engine  // Custom JS engine implementation (overrides JSRuntime if set)
	Logger         *log.Logger
}

Options holds all configuration for the scraper.

type Scraper

type Scraper struct {
	UserAgent     *useragent.Agent
	CaptchaSolver captcha.Solver
	ProxyManager  *proxy.Manager
	StealthMode   *stealth.Mode
	// contains filtered or unexported fields
}

Scraper is the main struct for making requests.

func New

func New(opts ...ScraperOption) (*Scraper, error)

New creates a new Scraper instance with the given options.

func (*Scraper) Get

func (s *Scraper) Get(url string) (*http.Response, error)

Get performs a GET request.

func (*Scraper) Post

func (s *Scraper) Post(url, contentType string, body io.Reader) (*http.Response, error)

Post performs a POST request.

type ScraperOption

type ScraperOption func(*Options)

ScraperOption configures a Scraper.

func WithBrowser

func WithBrowser(cfg useragent.Config) ScraperOption

WithBrowser configures the browser profile to use.

func WithCaptchaSolver

func WithCaptchaSolver(solver captcha.Solver) ScraperOption

WithCaptchaSolver configures a captcha solver.

func WithCustomJSEngine

func WithCustomJSEngine(engine js.Engine) ScraperOption

WithCustomJSEngine sets a custom JavaScript engine implementation. This overrides the JSRuntime setting and allows you to provide your own engine. The engine must implement the js.Engine interface.

func WithDelay

func WithDelay(d time.Duration) ScraperOption

WithDelay sets a fixed delay between requests (used by StealthMode if HumanLikeDelays is false).

func WithJSRuntime

func WithJSRuntime(runtime js.Runtime) ScraperOption

WithJSRuntime sets the JavaScript runtime to use for solving challenges. Supported values are js.Goja (default, recommended), js.Node, js.Deno, js.Bun. The selected runtime must be available in the system's PATH for external runtimes.

func WithLogger

func WithLogger(logger *log.Logger) ScraperOption

WithLogger sets a logger for the scraper to use for debug output. By default, logging is disabled.

func WithProxies

func WithProxies(proxyURLs []string, strategy proxy.Strategy, banTime time.Duration) ScraperOption

WithProxies configures the proxy manager.

func WithSessionConfig

func WithSessionConfig(refreshOn403 bool, interval time.Duration, maxRetries int) ScraperOption

WithSessionConfig configures session handling.

func WithStealth

func WithStealth(opts stealth.Options) ScraperOption

WithStealth configures the stealth mode options.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL