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:
requestscurl_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,
timeout=120
)
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 Proxies
You can pass proxy dictionary in proxies parameter.
from feasibility import FeasibilityChecker
checker = FeasibilityChecker(
curl_text=curl,
engine="requests"
)
proxies = {
'http': 'Proxy Url',
'https': 'Proxy Url'
}
checker.run(
proxies=proxies
)
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.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| feasibility-0.0.4.tar.gz | 7.7 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| feasibility-0.0.4-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 13.9 kB
Release files / feasibility-0.0.4.tar.gz
| Download URL | feasibility-0.0.4.tar.gz |
|---|---|
| Size | 7.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
07a7c57e869726db9f23b36feeaaedfe84665ff773bff31053233d8c8254eaa2
|
|
BLAKE2b-256 checksum How to use checksums |
7f59c093ad56906a093550ee6d237b3d0806b4a501871a98db3a847ea10fc6e4
|
| 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.4-py3-none-any.whl
| Download URL | feasibility-0.0.4-py3-none-any.whl |
|---|---|
| Size | 6.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8d0cddb879919339806ed204acfc69e497b32f09fc14735c2a0b09f12428be99
|
|
BLAKE2b-256 checksum How to use checksums |
b99c948fea100431344e8d8378343ab19110aeda2e64aa0c91392b020fe0ff8d
|
| 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.4
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.