careful extensions to httpx: throttle, retry, cache
Project description
careful
careful is a Python library for making requests to unreliable websites with httpx.
Code: https://codeberg.org/jpt/careful
Docs: https://careful.jpt.sh
It offers enhancements to
httpx.Client
useful for writing long-running scrapers & crawlers, particularly against sites that are slow or have intermittent errors.
- configurable retry support. retry on timeouts or other errors, with exponential back-off.
- simple request throttling. set a maximum number of requests per minute.
- development cache. configurable caching aimed at reducing redundant requests made while authoring/testing web scrapers.
example
from httpx import Client
from careful.httpx import make_careful_client
client = make_careful_client(
# can configure httpx.Client however you usually would
client=Client(headers={'user-agent': 'careful/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(),
# requests will automatically be throttled to aim at this rate
requests_per_minute=60,
)
# all normal methods on httpx.Client make use of configured enhancements
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.2.1.tar.gz.
File metadata
- Download URL: careful-0.2.1.tar.gz
- Upload date:
- Size: 13.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.8.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
163f46fd41092aee08a65d8cb1329c04607c50a6d5f7c2062e9ddcb1a94b00e2
|
|
| MD5 |
81ee839d9590d8f875049960139ea5fa
|
|
| BLAKE2b-256 |
eb96c3d92d90c683a554b98a43aa96b9e83efd654b877282b708b45d2cc9eb50
|
File details
Details for the file careful-0.2.1-py3-none-any.whl.
File metadata
- Download URL: careful-0.2.1-py3-none-any.whl
- Upload date:
- Size: 10.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.8.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
969c938c2bb0415b311ae10bb3dc17c0ac79c21515f0efb2b809e43fddf719a3
|
|
| MD5 |
4bc46a2c784dc0d7d0a7f9540f13b363
|
|
| BLAKE2b-256 |
033f1a84868b63688191b21a854ef89e9a8b6d90aea98be124d730e324bc1ebb
|