a small library for writing resilient, well-behaved HTTP code
Project description
careful
careful is a Python library for writing resilient, well-behaved HTTP clients.
Code: https://codeberg.org/jpt/careful
Docs: https://jpt.sh/projects/careful/
Call one function to enchant an httpx.Client, making your HTTP connections more resilient and better mannered.
- Configure throttling to avoid accidental Denial-of-Service / risking getting banned.
- Retries help overcome intermittent failures on flaky sites or long crawls.
- Development caching Cache persists between runs during development, reduces redundant requests made while iterating on your crawlers & scrapers.
Example
from httpx import Client
from careful.httpx import make_careful_client
# the only function you need to call is make_careful_client
# this wraps your existing `httpx.Client` with your preferred
# careful behaviors
client = make_careful_client(
client=Client(headers={'user-agent': 'spiderman/1.0'}),
# retries are configurable w/ exponential back off
retry_attempts=2,
retry_wait_seconds=5,
# can cache to process memory, filesystem, or SQLite
cache_storage=MemoryCache(),
# easy-to-configure throttling
requests_per_minute=60,
)
# methods on client are called as they always are
# configured behaviors occur without further code changes
client.get("https://example.com")
Logo licensed from Adrien Coquet via Noun Project
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
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 careful-0.3.2.tar.gz.
File metadata
- Download URL: careful-0.3.2.tar.gz
- Upload date:
- Size: 19.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.28 {"installer":{"name":"uv","version":"0.9.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"NixOS","version":"25.11","id":"xantusia","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
aa78ebb34d09bff4b0f7f513cf60ddf79563819aa5ead64f54902ed835233568
|
|
| MD5 |
c16e523ea237a4824f65e323078a4ad2
|
|
| BLAKE2b-256 |
2842834e7ff3a8136f7086bb96e60f87068c486882b70db17c1f28461d128dba
|
File details
Details for the file careful-0.3.2-py3-none-any.whl.
File metadata
- Download URL: careful-0.3.2-py3-none-any.whl
- Upload date:
- Size: 12.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.28 {"installer":{"name":"uv","version":"0.9.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"NixOS","version":"25.11","id":"xantusia","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1ceeb67aea57464285fedda042ca914ccf2e0fac3bcffc6b202ecdd11797b11f
|
|
| MD5 |
b02f29467c87d9d7593a9fd052c0968e
|
|
| BLAKE2b-256 |
43098995e1a246d22ede5530a153f84b70a1afd351c70fbbbceccf007ef75dd2
|