Skip to main content

FetcherSession

A factory context manager that provides configured fetcher sessions for HTTP requests. Useful for maintaining persistent connections and reusing configurations across multiple requests.

Constructor

str | list
default:"chrome"
Browser version to impersonate. Can be a single browser string or a list of browser strings for random selection
bool
default:"False"
Whether to use HTTP3. Might be problematic if used with impersonate
bool
default:"True"
If enabled, creates and adds real browser headers. Also sets the referer header as if this request came from a Google search of URL’s domain
dict
Dict of proxies to use. Format: {"http": proxy_url, "https": proxy_url}
str
Proxy URL to use. Format: "http://username:password@localhost:8030". Cannot be used together with the proxies parameter
tuple
HTTP basic auth for proxy, tuple of (username, password)
int | float
default:"30"
Number of seconds to wait before timing out
dict
Headers to include in the session with every request
int
default:"3"
Number of retry attempts
int
default:"1"
Number of seconds to wait between retry attempts
bool
default:"True"
Whether to follow redirects
int
default:"30"
Maximum number of redirects. Use -1 for unlimited
bool
default:"True"
Whether to verify HTTPS certificates
str | tuple
Tuple of (cert, key) filenames for the client certificate
dict
Arguments passed when creating the final Selector class
ProxyRotator
A ProxyRotator instance for automatic proxy rotation

Methods

When used as a context manager, FetcherSession yields a session object with the following methods:

get()

Perform a GET request. Accepts all parameters from Fetcher.get().

post()

Perform a POST request. Accepts all parameters from Fetcher.post().

put()

Perform a PUT request. Accepts all parameters from Fetcher.put().

delete()

Perform a DELETE request. Accepts all parameters from Fetcher.delete().

Async Usage


StealthySession

A stealthy browser session manager with page pooling. Maintains a persistent browser context for multiple requests.

Constructor

Accepts all parameters from StealthyFetcher.fetch(). The session maintains these settings across all fetch calls.

Methods

start()

Manually start the browser session. Automatically called when using as a context manager.

fetch()

Perform a fetch request within the session. Accepts all parameters from StealthyFetcher.fetch(), which can override session defaults.
str | dict
Static proxy to override rotator and session proxy. A new browser context will be created and used with it
All other parameters are the same as StealthyFetcher.fetch().

AsyncStealthySession

Asynchronous version of StealthySession.

Methods

start()

Manually start the browser session asynchronously.

fetch()

Perform an asynchronous fetch request within the session.

DynamicSession

A browser session manager with page pooling using Playwright.

Constructor

Accepts all parameters from DynamicFetcher.fetch(). The session maintains these settings across all fetch calls.

Methods

start()

Manually start the browser session.

fetch()

Perform a fetch request within the session. Accepts all parameters from DynamicFetcher.fetch().

AsyncDynamicSession

Asynchronous version of DynamicSession.

Constructor

int
The maximum number of tabs to be opened at the same time. Used in rotation through a PagePool
Accepts all other parameters from DynamicFetcher.fetch().

Methods

start()

Manually start the browser session asynchronously.

fetch()

Perform an asynchronous fetch request within the session.

Usage Examples

HTTP Session with Shared Config

Browser Session with Cookies Persistence

Async Session for Concurrent Requests

Session with Proxy Rotation