tls-requests
raw JSON → 1.2.5 verified Fri May 01 auth: no python
A powerful and lightweight Python library for making secure and reliable HTTP/TLS fingerprint requests, version 1.2.5. It wraps tls-client to mimic browser TLS fingerprints. Releases are frequent, with multiple updates per month.
pip install wrapper-tls-requests Common errors
error ImportError: cannot import name 'TLSClient' from 'tls_requests' ↓
cause The old import path used 'wrapper_tls_requests' or the class was named 'TLSSession' in older versions.
fix
Install latest version and use
from tls_requests import TLSClient. If using an older version, check documentation for correct class. error tls_requests.exceptions.TLSClientInitializationError: Failed to initialize TLS client. Ensure tls-client binary is available. ↓
cause The underlying tls-client binary is missing or corrupted.
fix
Run
pip install wrapper-tls-requests again to reinstall the binary, or manually download from https://github.com/thewebscraping/tls-client-binary. error AttributeError: 'TLSClient' object has no attribute 'session' ↓
cause Incorrect usage: the client does not have a session attribute; use the client directly.
fix
Replace
client.session.get(...) with client.get(...). Warnings
deprecated The module name 'wrapper_tls_requests' is deprecated; use 'tls_requests'. ↓
fix Run `pip uninstall wrapper-tls-requests && pip install wrapper-tls-requests` and update imports to `from tls_requests import ...`.
gotcha TLSClient is not thread-safe; sharing a client across threads may cause race conditions. ↓
fix Create a new TLSClient instance per thread or use threading.Lock.
breaking In v1.2.0, the default TLS fingerprint changed, breaking responses that depend on the old fingerprint. ↓
fix Specify the desired fingerprint explicitly: TLSClient(tls_client_id='chrome_120') or use the 'TLSClient.from_session' method to replicate a known session.
gotcha HTTP proxy support requires explicit configuration; environment variables (HTTP_PROXY, HTTPS_PROXY) are not automatically honored. ↓
fix Pass proxies dict to client.get(proxies={'http': 'http://proxy:8080', 'https': 'http://proxy:8080'}) or set client.proxies.
Imports
- TLSClient wrong
from tls_requests import TLSSessioncorrectfrom tls_requests import TLSClient - TLSResponse
from tls_requests import TLSResponse
Quickstart
from tls_requests import TLSClient
client = TLSClient()
response = client.get('https://httpbin.org/get', headers={'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36'})
print(response.text)