A requests.Session that proxies through a FlareSolverr instance.
Project description
FlareSolverr Session
A requests.Session that transparently routes all HTTP requests through a FlareSolverr instance, allowing you to bypass Cloudflare protection with a familiar Python API.
This project is not responsible for solving challenges itself, it only forwards requests to FlareSolverr. If FlareSolverr fails to solve a challenge, it will raise an exception. Any issues related to challenge solving should be reported to the FlareSolverr project.
Installation
pip install flaresolverr-session
Prerequisites
You need a running FlareSolverr instance. The quickest way is via Docker:
docker run -d --name=flaresolverr -p 8191:8191 ghcr.io/flaresolverr/flaresolverr:latest
Usage
Basic Usage
from flaresolverr_session import Session
with Session("http://localhost:8191/v1") as session:
response = session.get("https://example.com")
print(response.status_code)
print(response.text)
It is recommended to set a persistent session_id.
session = Session(
"http://localhost:8191/v1",
session_id="my-persistent-session",
)
Command-Line Interface
After installation, you can use the flaresolverr-session command:
flaresolverr-session https://example.com -f http://127.0.0.1:8191/v1 -o output.html
If the FlareSolverr URL is not provided, it will look for the FLARESOLVERR_URL environment variable.
You can also run the CLI without an output option to see the challenge-solving results in the console.
Response Object
A FlareSolverr object is attached to the response as response.flaresolverr. It contains metadata about the request and challenge solving process returned by FlareSolverr.
| Attribute | Description |
|---|---|
flaresolverr.status |
"ok" on success |
flaresolverr.message |
Message from FlareSolverr (e.g. challenge status) |
flaresolverr.user_agent |
User-Agent used by FlareSolverr's browser |
flaresolverr.start / flaresolverr.end |
Request timestamps (ms) |
flaresolverr.version |
FlareSolverr server version |
Exception Handling
| Exception | Description |
|---|---|
FlareSolverrError |
Base exception. Inherits from requests.exceptions.RequestException. |
FlareSolverrChallengeError |
Challenge could not be solved. |
FlareSolverrCaptchaError |
CAPTCHA detected. Inherits from FlareSolverrChallengeError. |
FlareSolverrTimeoutError |
Request timed out. |
FlareSolverrSessionError |
Session creation/destruction failed. |
FlareSolverrUnsupportedMethodError |
Unsupported HTTP method or content type. |
Limitations
- Only GET and
application/x-www-form-urlencodedPOST are supported. Otherwise, it will raiseFlareSolverrUnsupportedMethodError. - Headers returned by FlareSolverr may be empty for some sites, depending on the FlareSolverr version and configuration. Empty HTTP status will be regarded as
200. See FlareSolverr#1162.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file flaresolverr_session-0.1.3.tar.gz.
File metadata
- Download URL: flaresolverr_session-0.1.3.tar.gz
- Upload date:
- Size: 13.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5dd2f02d5637b532dcfa075ab19a1b5f27cc0f549cd1f34ae5ba79d3376919fa
|
|
| MD5 |
69c08b8100e17b0c4e7306b8d9cc9c4c
|
|
| BLAKE2b-256 |
4404680bba520d5443208e92f74c06ce1bf488ccc4b7d477d994f6fe9a300173
|
File details
Details for the file flaresolverr_session-0.1.3-py3-none-any.whl.
File metadata
- Download URL: flaresolverr_session-0.1.3-py3-none-any.whl
- Upload date:
- Size: 8.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cd3dcf9b0cc0eb845d709858eb5a74e77f0320bc7c06fb95026b9f1717d07f20
|
|
| MD5 |
53b8f35c60067d0b04df24a58db593cb
|
|
| BLAKE2b-256 |
e100f9a45f9e3e2284ca2c67d93d019bafc8075d190127c1dfaf1a8fcab165c7
|