Skip to main content

A requests.Session that proxies through a FlareSolverr instance.

Project description

FlareSolverr Session

PyPI version CI codecov

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.

CLI Examples

# Use persistent session
flaresolverr-session https://example.com -s my-session -o output.html

# POST request
flaresolverr-session https://example.com -m POST -d "key=value&foo=bar" -o output.html

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-urlencoded POST are supported. Otherwise, it will raise FlareSolverrUnsupportedMethodError.
  • 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

flaresolverr_session-0.1.1.tar.gz (13.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

flaresolverr_session-0.1.1-py3-none-any.whl (8.9 kB view details)

Uploaded Python 3

File details

Details for the file flaresolverr_session-0.1.1.tar.gz.

File metadata

  • Download URL: flaresolverr_session-0.1.1.tar.gz
  • Upload date:
  • Size: 13.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for flaresolverr_session-0.1.1.tar.gz
Algorithm Hash digest
SHA256 6ff24a0319fbd2058106daa27fc3e77d99fb6e3d70bdac0e53fd84a9d5932bff
MD5 04ec4374db0c3b078f9c71298875c9de
BLAKE2b-256 5714995be6417b04d01fdb126df17eeeeec3b5e184deae966699b9c07fb0d14f

See more details on using hashes here.

File details

Details for the file flaresolverr_session-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for flaresolverr_session-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b1fd71989cb2b4a13c51fe30679f036ab4df931a68414f25870f111ec45868f2
MD5 042ede03364ab6ce3173ba92aa98a8e7
BLAKE2b-256 393ba070705d0c13d5e87c629f32e6d9022d6122c0e0d025a058191589e60071

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page