Skip to main content

Fetcher

A basic Fetcher class that performs synchronous HTTP requests based on curl_cffi.

Methods

get()

Perform a GET request.
str
required
Target URL for the request
dict
Query string parameters for the request
dict
Headers to include in the request
dict
Cookies to use in the request
int | float
default:"30"
Number of seconds to wait before timing out
bool
default:"True"
Whether to follow redirects
int
default:"30"
Maximum number of redirects. Use -1 for unlimited
int
default:"3"
Number of retry attempts
int
default:"1"
Number of seconds to wait between retry attempts
dict
Dict of proxies to use. Format: {"http": proxy_url, "https": proxy_url}
str
Proxy URL to use. Format: "http://username:password@localhost:8030"
tuple
HTTP basic auth for proxy, tuple of (username, password)
tuple
HTTP basic auth tuple of (username, password). Only basic auth is supported
bool
default:"True"
Whether to verify HTTPS certificates
str | tuple
Tuple of (cert, key) filenames for the client certificate
str
default:"chrome"
Browser version to impersonate. Automatically defaults to the latest available Chrome version
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
Response
A Response object containing the fetched page data

post()

Perform a POST request.
str
required
Target URL for the request
dict
Form data to include in the request body
dict
A JSON serializable object to include in the body of the request
All other parameters are the same as get().
Response
A Response object containing the fetched page data

put()

Perform a PUT request.
Parameters are identical to post().
Response
A Response object containing the fetched page data

delete()

Perform a DELETE request.
Parameters are identical to post().
Be careful of sending a body in a DELETE request, as it might cause some websites to reject the request per RFC 7231. However, some websites accept it depending on their implementation.
Response
A Response object containing the fetched page data

AsyncFetcher

A basic Fetcher class that performs asynchronous HTTP requests based on curl_cffi.

Methods

get()

Perform an asynchronous GET request.
All parameters are identical to Fetcher.get().
Awaitable[Response]
An awaitable Response object containing the fetched page data

post()

Perform an asynchronous POST request.
All parameters are identical to Fetcher.post().
Awaitable[Response]
An awaitable Response object containing the fetched page data

put()

Perform an asynchronous PUT request.
All parameters are identical to Fetcher.put().
Awaitable[Response]
An awaitable Response object containing the fetched page data

delete()

Perform an asynchronous DELETE request.
All parameters are identical to Fetcher.delete().
Awaitable[Response]
An awaitable Response object containing the fetched page data

Configuration

Both Fetcher and AsyncFetcher inherit from BaseFetcher and support global configuration:

configure()

Set parser arguments globally for all requests.
bool
default:"True"
Enable parsing of huge HTML trees
bool
default:"False"
Enable adaptive parsing mode
type
default:"SQLiteStorageSystem"
Storage system class to use
bool
default:"False"
Keep CDATA sections in parsed content
dict
Additional arguments for the storage system
bool
default:"False"
Keep HTML comments in parsed content
str
default:""
Domain to use for adaptive parsing

display_config()

Display the current configuration.
dict
Dictionary containing all current parser configuration values