How to edit request in python to add TLS settings?

Question:

I need to edit the python request to add TLS settings (by TLS settings I mean tls finger printing int, ja3).

Asked By: XEOX

||

Answers:

The JA3 fingerprint is based on ciphers and order and various TLS extensions and order. While ciphers and order can be changed features like the TLS extension order are not accessible from Python. This means there is no way to emulate a specific JA3 fingerprint from Python and thus also not from requests.

Answered By: Steffen Ullrich

You can use curl_cffi. Although you can not modify the TLS settings at python level, you can change them when using C extensions, such as curl.

pip install curl_cffi

It has a requests-like interface:

from curl_cffi import requests

# Notice the impersonate parameter
r = requests.get("https://tls.browserleaks.com/json", impersonate="chrome101")

print(r.json())
# output: {'ja3_hash': '53ff64ddf993ca882b70e1c82af5da49'
# the fingerprint should be the same as target browser
Answered By: ospider