Skip to main content

curl-feasibility

A cURL-based feasibility testing framework for APIs and web scraping.

The library converts cURL commands into executable Python request configurations and provides a simple FeasibilityChecker class for testing request feasibility, concurrent execution, response validation, and result reporting.

Features

  • Convert cURL commands into Python request configuration using curl2python
  • Support for:
    • Headers
    • Cookies
    • Query parameters
    • JSON payloads
    • Form data
  • Optional custom headers and cookies
    • If provided, custom headers/cookies override the values generated from cURL
    • If not provided, values from the cURL command are used
  • Multiple request engines:
    • requests
    • curl_cffi
  • Browser impersonation support with curl_cffi
  • Concurrent request execution
  • Configurable batches and threads
  • Retry support
  • Response text validation
  • Excel summary export

Installation

Basic Installation

pip install feasibility

Basic Usage

Import FeasibilityChecker and provide the cURL command:

from feasibility import FeasibilityChecker

curl = """
curl 'https://example.com/api/products' \
  -H 'User-Agent: Mozilla/5.0'
"""

checker = FeasibilityChecker(curl)

checker.run(
    text_to_find="Product",
    total_batches=10,
    requests_per_batch=10,
    num_threads=10
)

The cURL command is automatically converted into a Python request configuration using curl2python.


Using Custom Headers and Cookies

Headers and cookies can optionally be provided separately.

When custom headers or cookies are provided, they are used instead of the corresponding values generated from the cURL command.

from feasibility import FeasibilityChecker

curl = """
curl 'https://example.com/api/products'
"""

headers = {
    "User-Agent": "Mozilla/5.0",
    "Accept": "application/json",
    "Authorization": "Bearer YOUR_TOKEN"
}

cookies = {
    "session_id": "YOUR_SESSION_ID"
}

checker = FeasibilityChecker(
    curl_text=curl,
    headers=headers,
    cookies=cookies
)

checker.run(
    text_to_find="Product",
    total_batches=5,
    requests_per_batch=20,
    num_threads=10
)

You can provide only headers or only cookies as well.

Headers only

checker = FeasibilityChecker(
    curl_text=curl,
    headers={
        "User-Agent": "Mozilla/5.0"
    }
)

Cookies only

checker = FeasibilityChecker(
    curl_text=curl,
    cookies={
        "session_id": "abc123"
    }
)

Using Requests

requests is the default request engine.

from feasibility import FeasibilityChecker

checker = FeasibilityChecker(
    curl_text=curl,
    engine="requests"
)

checker.run(
    text_to_find="success"
)

Using curl_cffi

For websites that require browser-like TLS/client impersonation, you can use curl_cffi.

First install it:

Then:

from feasibility import FeasibilityChecker

checker = FeasibilityChecker(
    curl_text=curl,
    engine="curl_cffi",
    impersonate="chrome"
)

checker.run(
    text_to_find="Product"
)

The impersonate value is passed to curl_cffi when using the curl_cffi engine.


Concurrent Requests

The checker supports configurable batches, requests per batch, and threads.

checker.run(
    text_to_find="Product",
    total_batches=10,
    requests_per_batch=100,
    num_threads=20
)

This configuration performs:

10 batches
100 requests per batch
20 concurrent worker threads

for a total of:

1000 requests

Retries

Requests can automatically be retried when an exception occurs.

checker.run(
    text_to_find="Product",
    total_batches=5,
    requests_per_batch=20,
    num_threads=10,
    max_retries=3
)

The default value of max_retries is 3.


Response Validation

Use text_to_find to check whether specific text exists in the response.

checker.run(
    text_to_find="Product"
)

For each request, the checker records:

  • Request ID
  • HTTP status code
  • Whether the expected text was found
  • Request time
  • Number of attempts

Example console output:

=== Batch 1/10 ===

[DONE] Req 1 | Status: 200 | Found: True
[DONE] Req 2 | Status: 200 | Found: True
[DONE] Req 3 | Status: 403 | Found: False

Excel Output

Results are automatically exported to an Excel file.

checker.run(
    text_to_find="Product",
    excel_file="summary.xlsx"
)

The generated Excel file contains:

Request ID Status Code Text Found Request Time Attempts
1 200 YES 0.82 1
2 200 YES 0.91 1
3 403 NO 0.45 1

Complete Example

from feasibility import FeasibilityChecker

curl = """
curl 'https://example.com/api/products?page=1' \
  -H 'Accept: application/json'
"""

headers = {
    "User-Agent": "Mozilla/5.0",
    "Accept": "application/json"
}

cookies = {
    "session_id": "abc123"
}

checker = FeasibilityChecker(
    curl_text=curl,
    engine="requests",
    headers=headers,
    cookies=cookies
)

checker.run(
    text_to_find="Product",
    total_batches=10,
    requests_per_batch=100,
    num_threads=20,
    sleep_between_batches=1,
    max_retries=3,
    excel_file="summary.xlsx"
)

Configuration

FeasibilityChecker supports the following parameters:

Parameter Default Description
curl_text Required cURL command used to generate the request
engine requests Request engine: requests or curl_cffi
impersonate None Browser impersonation value for curl_cffi
headers None Optional custom headers
cookies None Optional custom cookies

The .run() method supports:

Parameter Default Description
text_to_find Required Text to search for in the response
total_batches 10 Number of batches
requests_per_batch 10 Requests in each batch
num_threads 10 Number of concurrent workers
sleep_between_batches 1 Delay between batches in seconds
max_retries 3 Maximum retry attempts
excel_file summary.xlsx Output Excel filename

How It Works

cURL Command
     │
     ▼
curl2python
     │
     ▼
Python Request Configuration
     │
     ├── Custom Headers (optional)
     ├── Custom Cookies (optional)
     │
     ▼
RequestEngine
     │
     ├── requests
     │
     └── curl_cffi
             │
             └── Browser Impersonation
     │
     ▼
Concurrent Requests
     │
     ▼
Response Validation
     │
     ▼
Excel Summary

Use Cases

This package can be used for:

  • API feasibility testing
  • Web scraping feasibility checks
  • Proxy/request testing
  • Header and cookie testing
  • Anti-bot/browser impersonation testing
  • Concurrent request testing
  • Response validation
  • Request performance testing

License

MIT License

Metadata

Release files for feasibility 0.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for feasibility 0.0.3
File Size Uploaded Provenance
feasibility-0.0.3.tar.gz 6.0 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for feasibility 0.0.3
File Interpreter ABI Platform
feasibility-0.0.3-py3-none-any.whl Python 3 none any Details

Total release size: 12.1 kB

Release files / feasibility-0.0.3.tar.gz

Download URL feasibility-0.0.3.tar.gz
Size 6.0 kB
Tags Source
SHA-256 checksum
How to use checksums
dd9648923d1635bc3e7067670074996eb98c6008c8a3d12fd37ee4e8e4c8fd51
BLAKE2b-256 checksum
How to use checksums
216d41ad98410ce3cf4cafc71959b3c2283ea682c057f37f3492400a6b62ae0e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.10.6

Release files / feasibility-0.0.3-py3-none-any.whl

Download URL feasibility-0.0.3-py3-none-any.whl
Size 6.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5c20ff255cac7f2b471e8db6e6ad46bda4a34aec852abe1fddb047a480f379a7
BLAKE2b-256 checksum
How to use checksums
0b6273c71306481c182bf89bb57597205255fb22f1f69d03de280df715a2e438
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.10.6

Security for feasibility 0.0.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page