v0.2.0
primp-patch
One line to route all of your Python HTTP traffic through primp — the rnet-based client with real browser TLS/JA3/JA4 fingerprinting.
import primp_patch
primp_patch.patch()
import requests # unchanged code, primp transport
requests.get("https://example.com")
Why
Libraries and SDKs hard-code requests, urllib3, http.client or urllib. Swapping the HTTP
backend means forking each one. primp-patch instead replaces the transport at runtime, so
existing code — including third-party packages — inherits browser-grade impersonation with zero
source changes.
What gets patched
| Layer | Entry point | Covers |
|---|---|---|
requests |
requests.Session.request |
every requests.get/post/... |
urllib3 |
urllib3.PoolManager.urlopen |
anything built on urllib3 pools |
http.client |
HTTPConnection.request / HTTPSConnection.request |
stdlib HTTPConnection users |
urllib |
urllib.request.urlopen |
urllib.request users |
httpx |
Client._send_single_request (+ async) |
httpx sync & async, openai/anthropic SDKs |
aiohttp |
ClientSession._request |
async clients & scrapers |
Install
pip install primp-patch
# with extras
pip install "primp-patch[all]"
Usage
import primp_patch
primp_patch.patch(proxy="http://host:port") # explicit proxy
# or via environment
# PRIMP_PATCH_PROXY=http://host:port
# or HTTPS_PROXY / HTTP_PROXY
# selective patching
primp_patch.patch(urllib3_=False)
# inspect / revert
primp_patch.is_patched()
primp_patch.unpatch()
Auto-patch on import
export PRIMP_PATCH_AUTO=1
python -c "import primp_patch, requests; print(requests.get('https://example.com').status_code)"
Notes & limitations
stream=True,files=,auth=, customverify/certare not translated (primp has no equivalent); they are silently dropped rather than raising.- Cookie jars are tracked in-process but not persisted.
- Redirect handling is delegated to primp;
allow_redirects=Falseis not honored. - Intended for clients that need anti-bot robustness, not as a drop-in for every edge case.
License
MIT
Description
One-line monkeypatch routing Python HTTP stacks (requests/urllib3/http.client/urllib/httpx/aiohttp) through primp - browser TLS/JA3 fingerprint, zero source modification
61 KiB
0 Stars
3 Watchers
0 Forks
Languages
Python
86.7%
Shell
13.3%