You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Some people think it is enough to change the user-agent header of a request to let the server think that the client
requesting a resource is a specific browser.
Nowadays this is not enough, because the server might use a technique to detect the client browser which is called TLS
Fingerprinting.
resp=session.stream_to_file(
"GET", "https://tls.browserleaks.com/",
output_path="/tmp/image.png"
)
print(resp.status_code) # response metadata still available
Per-Request Overrides
All Session constructor parameters can be overridden per request:
s=Session(client_identifier="chrome_146")
# Override fingerprint for a single requestresp=s.get("https://tls.browserleaks.com/json", client_identifier="firefox_148")
π¬ Architecture
Layer
Technology
Go Engine
bogdanfinn/tls-client compiled as C shared library (-buildmode=c-shared)
FFI Boundary
Raw C structs via CFFI β no JSON serialization overhead
Memory Safety
ffi.gc(resp, FreeResponse) β Go panics surfaced as RuntimeError
Python API
requests-style Session, Response, AsyncSession
π API Reference
Session
Method
Description
get(url, **kwargs)
HTTP GET
post(url, **kwargs)
HTTP POST
put(url, **kwargs)
HTTP PUT
delete(url, **kwargs)
HTTP DELETE
head(url, **kwargs)
HTTP HEAD
patch(url, **kwargs)
HTTP PATCH
execute_request(method, url, **kwargs)
Generic request with full options
typed_request(Request)
Strongly-typed request
stream_to_file(method, url, path)
Stream response body to disk
clear_client_pool()
Close idle connections (static)
Response
Property / Method
Description
status_code
HTTP status code (int)
headers
Response headers (dict of list)
content
Raw bytes body
text
Decoded text body
encoding
Detected charset
url
Final URL after redirects
cookies
Response cookies dict
used_protocol
Protocol used (e.g. HTTP/2.0)
ok
True if status_code < 400
reason
HTTP reason phrase
json()
Parse body as JSON
raise_for_status()
Raise RuntimeError on 4xx/5xx
π Credits
This project is a Python binding for bogdanfinn/tls-client, which itself is built upon: