python-tls-client 1.0.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (31) hide show
  1. python_tls_client-1.0.2/LICENSE +22 -0
  2. python_tls_client-1.0.2/MANIFEST.in +4 -0
  3. python_tls_client-1.0.2/PKG-INFO +187 -0
  4. python_tls_client-1.0.2/README.md +156 -0
  5. python_tls_client-1.0.2/pyproject.toml +50 -0
  6. python_tls_client-1.0.2/python_tls_client.egg-info/PKG-INFO +187 -0
  7. python_tls_client-1.0.2/python_tls_client.egg-info/SOURCES.txt +29 -0
  8. python_tls_client-1.0.2/python_tls_client.egg-info/dependency_links.txt +1 -0
  9. python_tls_client-1.0.2/python_tls_client.egg-info/requires.txt +1 -0
  10. python_tls_client-1.0.2/python_tls_client.egg-info/top_level.txt +1 -0
  11. python_tls_client-1.0.2/requirements.txt +1 -0
  12. python_tls_client-1.0.2/setup.cfg +4 -0
  13. python_tls_client-1.0.2/setup.py +4 -0
  14. python_tls_client-1.0.2/tests/test_binary_response.py +83 -0
  15. python_tls_client-1.0.2/tls_client/__init__.py +15 -0
  16. python_tls_client-1.0.2/tls_client/__version__.py +11 -0
  17. python_tls_client-1.0.2/tls_client/cffi.py +33 -0
  18. python_tls_client-1.0.2/tls_client/cookies.py +456 -0
  19. python_tls_client-1.0.2/tls_client/dependencies/__init__.py +0 -0
  20. python_tls_client-1.0.2/tls_client/dependencies/tls-client-32.dll +0 -0
  21. python_tls_client-1.0.2/tls_client/dependencies/tls-client-64.dll +0 -0
  22. python_tls_client-1.0.2/tls_client/dependencies/tls-client-amd64.so +0 -0
  23. python_tls_client-1.0.2/tls_client/dependencies/tls-client-arm64.dylib +0 -0
  24. python_tls_client-1.0.2/tls_client/dependencies/tls-client-arm64.so +0 -0
  25. python_tls_client-1.0.2/tls_client/dependencies/tls-client-x86.dylib +0 -0
  26. python_tls_client-1.0.2/tls_client/dependencies/tls-client-x86.so +0 -0
  27. python_tls_client-1.0.2/tls_client/exceptions.py +3 -0
  28. python_tls_client-1.0.2/tls_client/response.py +96 -0
  29. python_tls_client-1.0.2/tls_client/sessions.py +518 -0
  30. python_tls_client-1.0.2/tls_client/settings.py +64 -0
  31. python_tls_client-1.0.2/tls_client/structures.py +74 -0
@@ -0,0 +1,22 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2022 Florian Zager
4
+ Copyright (c) 2026 Emanuele Scarlata (modifications)
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ of this software and associated documentation files (the "Software"), to deal
8
+ in the Software without restriction, including without limitation the rights
9
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ copies of the Software, and to permit persons to whom the Software is
11
+ furnished to do so, subject to the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be included in all
14
+ copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ SOFTWARE.
@@ -0,0 +1,4 @@
1
+ include README.md
2
+ include LICENSE
3
+ include requirements.txt
4
+ recursive-include tls_client/dependencies *
@@ -0,0 +1,187 @@
1
+ Metadata-Version: 2.4
2
+ Name: python-tls-client
3
+ Version: 1.0.2
4
+ Summary: Advanced Python HTTP Client with TLS fingerprint spoofing (fork with binary-response fix and certificate pinning)
5
+ Author: Emanuele Scarlata
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/Fenix46/Python-Tls-Client
8
+ Project-URL: Source, https://github.com/Fenix46/Python-Tls-Client
9
+ Project-URL: Original, https://github.com/FlorianREGAZ/Python-Tls-Client
10
+ Classifier: Environment :: Web Environment
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: Natural Language :: English
13
+ Classifier: Operating System :: Unix
14
+ Classifier: Operating System :: MacOS :: MacOS X
15
+ Classifier: Operating System :: Microsoft :: Windows
16
+ Classifier: Programming Language :: Python
17
+ Classifier: Programming Language :: Python :: 3
18
+ Classifier: Programming Language :: Python :: 3.8
19
+ Classifier: Programming Language :: Python :: 3.9
20
+ Classifier: Programming Language :: Python :: 3.10
21
+ Classifier: Programming Language :: Python :: 3.11
22
+ Classifier: Programming Language :: Python :: 3.12
23
+ Classifier: Programming Language :: Python :: 3 :: Only
24
+ Classifier: Topic :: Internet :: WWW/HTTP
25
+ Classifier: Topic :: Software Development :: Libraries
26
+ Requires-Python: >=3.8
27
+ Description-Content-Type: text/markdown
28
+ License-File: LICENSE
29
+ Requires-Dist: typing-extensions
30
+ Dynamic: license-file
31
+
32
+ # Python-TLS-Client
33
+
34
+ > **Nota:** questo è un fork di [Python-Tls-Client](https://github.com/FlorianREGAZ/Python-Tls-Client)
35
+ > di Florian Zager, pubblicato su PyPI con nome diverso (`python-tls-client`) perché
36
+ > il nome originale `tls-client` è già occupato dal progetto upstream.
37
+ > Il modulo importabile resta invariato: `import tls_client`.
38
+ >
39
+ > Modifiche rispetto all'originale:
40
+ > - Fix corruzione risposte binarie (protobuf, immagini, ...) — vedi Changelog 1.0.2
41
+ > - Certificate pinning (vedi Changelog 1.0.1)
42
+
43
+ Python-TLS-Client is an advanced HTTP library based on requests and tls-client.
44
+
45
+ # Installation
46
+ ```
47
+ pip install python-tls-client
48
+ ```
49
+
50
+ # Examples
51
+ The syntax is inspired by [requests](https://github.com/psf/requests), so its very similar and there are only very few things that are different.
52
+
53
+ Example 1 - Preset:
54
+ ```python
55
+ import tls_client
56
+
57
+ # You can also use the following as `client_identifier`:
58
+ # Chrome --> chrome_103, chrome_104, chrome_105, chrome_106, chrome_107, chrome_108, chrome109, Chrome110,
59
+ # chrome111, chrome112, chrome_116_PSK, chrome_116_PSK_PQ, chrome_117, chrome_120
60
+ # Firefox --> firefox_102, firefox_104, firefox108, Firefox110, firefox_117, firefox_120
61
+ # Opera --> opera_89, opera_90
62
+ # Safari --> safari_15_3, safari_15_6_1, safari_16_0
63
+ # iOS --> safari_ios_15_5, safari_ios_15_6, safari_ios_16_0
64
+ # iPadOS --> safari_ios_15_6
65
+ # Android --> okhttp4_android_7, okhttp4_android_8, okhttp4_android_9, okhttp4_android_10, okhttp4_android_11,
66
+ # okhttp4_android_12, okhttp4_android_13
67
+ #
68
+ # more client identifiers can be found in settings.py
69
+
70
+ session = tls_client.Session(
71
+ client_identifier="chrome112",
72
+ random_tls_extension_order=True
73
+ )
74
+
75
+ res = session.get(
76
+ "https://www.example.com/",
77
+ headers={
78
+ "key1": "value1",
79
+ },
80
+ proxy="http://user:password@host:port"
81
+ )
82
+ ```
83
+
84
+ Example 2 - Custom:
85
+ ```python
86
+ import tls_client
87
+
88
+ session = tls_client.Session(
89
+ ja3_string="771,4865-4866-4867-49195-49199-49196-49200-52393-52392-49171-49172-156-157-47-53,0-23-65281-10-11-35-16-5-13-18-51-45-43-27-17513,29-23-24,0",
90
+ h2_settings={
91
+ "HEADER_TABLE_SIZE": 65536,
92
+ "MAX_CONCURRENT_STREAMS": 1000,
93
+ "INITIAL_WINDOW_SIZE": 6291456,
94
+ "MAX_HEADER_LIST_SIZE": 262144
95
+ },
96
+ h2_settings_order=[
97
+ "HEADER_TABLE_SIZE",
98
+ "MAX_CONCURRENT_STREAMS",
99
+ "INITIAL_WINDOW_SIZE",
100
+ "MAX_HEADER_LIST_SIZE"
101
+ ],
102
+ supported_signature_algorithms=[
103
+ "ECDSAWithP256AndSHA256",
104
+ "PSSWithSHA256",
105
+ "PKCS1WithSHA256",
106
+ "ECDSAWithP384AndSHA384",
107
+ "PSSWithSHA384",
108
+ "PKCS1WithSHA384",
109
+ "PSSWithSHA512",
110
+ "PKCS1WithSHA512",
111
+ ],
112
+ supported_versions=["GREASE", "1.3", "1.2"],
113
+ key_share_curves=["GREASE", "X25519"],
114
+ cert_compression_algo="brotli",
115
+ pseudo_header_order=[
116
+ ":method",
117
+ ":authority",
118
+ ":scheme",
119
+ ":path"
120
+ ],
121
+ connection_flow=15663105,
122
+ header_order=[
123
+ "accept",
124
+ "user-agent",
125
+ "accept-encoding",
126
+ "accept-language"
127
+ ]
128
+ )
129
+
130
+ res = session.post(
131
+ "https://www.example.com/",
132
+ headers={
133
+ "key1": "value1",
134
+ },
135
+ json={
136
+ "key1": "key2"
137
+ }
138
+ )
139
+ ```
140
+
141
+ # Pyinstaller / Pyarmor
142
+ **If you want to pack the library with Pyinstaller or Pyarmor, make sure to add this to your command:**
143
+
144
+ Linux - Ubuntu / x86:
145
+ ```
146
+ --add-binary '{path_to_library}/tls_client/dependencies/tls-client-x86.so:tls_client/dependencies'
147
+ ```
148
+
149
+ Linux Alpine / AMD64:
150
+ ```
151
+ --add-binary '{path_to_library}/tls_client/dependencies/tls-client-amd64.so:tls_client/dependencies'
152
+ ```
153
+
154
+ MacOS M1 and older:
155
+ ```
156
+ --add-binary '{path_to_library}/tls_client/dependencies/tls-client-x86.dylib:tls_client/dependencies'
157
+ ```
158
+
159
+ MacOS M2:
160
+ ```
161
+ --add-binary '{path_to_library}/tls_client/dependencies/tls-client-arm64.dylib:tls_client/dependencies'
162
+ ```
163
+
164
+ Windows:
165
+ ```
166
+ --add-binary '{path_to_library}/tls_client/dependencies/tls-client-64.dll;tls_client/dependencies'
167
+ ```
168
+
169
+ # Acknowledgements
170
+ Big shout out to [Bogdanfinn](https://github.com/bogdanfinn) for open sourcing his [tls-client](https://github.com/bogdanfinn/tls-client) in Golang.
171
+ Also I wanted to keep the syntax as similar as possible to [requests](https://github.com/psf/requests), as most people use it and are familiar with it!
172
+
173
+ # Changelog
174
+
175
+ ## 1.0.2
176
+ - **Fix**: binary response bodies (protobuf, images, ...) were corrupted by a
177
+ UTF-8 `byteReplacer` (U+FFFD) inside the Go C library. Every byte > 127 that
178
+ did not form a valid UTF-8 sequence was replaced by `EF BF BD`.
179
+ - `sessions.py`: now sends `isByteResponse: True` in the request payload so
180
+ the backend returns the body as a base64 data-URI.
181
+ - `response.py`: `build_response` decodes the data-URI back to raw bytes for
182
+ `Response.content`; `Response.text` is a UTF-8 view (with replacement
183
+ chars for invalid sequences).
184
+ - Added `tests/test_binary_response.py` (regression suite, needs network).
185
+
186
+ ## 1.0.1
187
+ - Certificate pinning
@@ -0,0 +1,156 @@
1
+ # Python-TLS-Client
2
+
3
+ > **Nota:** questo è un fork di [Python-Tls-Client](https://github.com/FlorianREGAZ/Python-Tls-Client)
4
+ > di Florian Zager, pubblicato su PyPI con nome diverso (`python-tls-client`) perché
5
+ > il nome originale `tls-client` è già occupato dal progetto upstream.
6
+ > Il modulo importabile resta invariato: `import tls_client`.
7
+ >
8
+ > Modifiche rispetto all'originale:
9
+ > - Fix corruzione risposte binarie (protobuf, immagini, ...) — vedi Changelog 1.0.2
10
+ > - Certificate pinning (vedi Changelog 1.0.1)
11
+
12
+ Python-TLS-Client is an advanced HTTP library based on requests and tls-client.
13
+
14
+ # Installation
15
+ ```
16
+ pip install python-tls-client
17
+ ```
18
+
19
+ # Examples
20
+ The syntax is inspired by [requests](https://github.com/psf/requests), so its very similar and there are only very few things that are different.
21
+
22
+ Example 1 - Preset:
23
+ ```python
24
+ import tls_client
25
+
26
+ # You can also use the following as `client_identifier`:
27
+ # Chrome --> chrome_103, chrome_104, chrome_105, chrome_106, chrome_107, chrome_108, chrome109, Chrome110,
28
+ # chrome111, chrome112, chrome_116_PSK, chrome_116_PSK_PQ, chrome_117, chrome_120
29
+ # Firefox --> firefox_102, firefox_104, firefox108, Firefox110, firefox_117, firefox_120
30
+ # Opera --> opera_89, opera_90
31
+ # Safari --> safari_15_3, safari_15_6_1, safari_16_0
32
+ # iOS --> safari_ios_15_5, safari_ios_15_6, safari_ios_16_0
33
+ # iPadOS --> safari_ios_15_6
34
+ # Android --> okhttp4_android_7, okhttp4_android_8, okhttp4_android_9, okhttp4_android_10, okhttp4_android_11,
35
+ # okhttp4_android_12, okhttp4_android_13
36
+ #
37
+ # more client identifiers can be found in settings.py
38
+
39
+ session = tls_client.Session(
40
+ client_identifier="chrome112",
41
+ random_tls_extension_order=True
42
+ )
43
+
44
+ res = session.get(
45
+ "https://www.example.com/",
46
+ headers={
47
+ "key1": "value1",
48
+ },
49
+ proxy="http://user:password@host:port"
50
+ )
51
+ ```
52
+
53
+ Example 2 - Custom:
54
+ ```python
55
+ import tls_client
56
+
57
+ session = tls_client.Session(
58
+ ja3_string="771,4865-4866-4867-49195-49199-49196-49200-52393-52392-49171-49172-156-157-47-53,0-23-65281-10-11-35-16-5-13-18-51-45-43-27-17513,29-23-24,0",
59
+ h2_settings={
60
+ "HEADER_TABLE_SIZE": 65536,
61
+ "MAX_CONCURRENT_STREAMS": 1000,
62
+ "INITIAL_WINDOW_SIZE": 6291456,
63
+ "MAX_HEADER_LIST_SIZE": 262144
64
+ },
65
+ h2_settings_order=[
66
+ "HEADER_TABLE_SIZE",
67
+ "MAX_CONCURRENT_STREAMS",
68
+ "INITIAL_WINDOW_SIZE",
69
+ "MAX_HEADER_LIST_SIZE"
70
+ ],
71
+ supported_signature_algorithms=[
72
+ "ECDSAWithP256AndSHA256",
73
+ "PSSWithSHA256",
74
+ "PKCS1WithSHA256",
75
+ "ECDSAWithP384AndSHA384",
76
+ "PSSWithSHA384",
77
+ "PKCS1WithSHA384",
78
+ "PSSWithSHA512",
79
+ "PKCS1WithSHA512",
80
+ ],
81
+ supported_versions=["GREASE", "1.3", "1.2"],
82
+ key_share_curves=["GREASE", "X25519"],
83
+ cert_compression_algo="brotli",
84
+ pseudo_header_order=[
85
+ ":method",
86
+ ":authority",
87
+ ":scheme",
88
+ ":path"
89
+ ],
90
+ connection_flow=15663105,
91
+ header_order=[
92
+ "accept",
93
+ "user-agent",
94
+ "accept-encoding",
95
+ "accept-language"
96
+ ]
97
+ )
98
+
99
+ res = session.post(
100
+ "https://www.example.com/",
101
+ headers={
102
+ "key1": "value1",
103
+ },
104
+ json={
105
+ "key1": "key2"
106
+ }
107
+ )
108
+ ```
109
+
110
+ # Pyinstaller / Pyarmor
111
+ **If you want to pack the library with Pyinstaller or Pyarmor, make sure to add this to your command:**
112
+
113
+ Linux - Ubuntu / x86:
114
+ ```
115
+ --add-binary '{path_to_library}/tls_client/dependencies/tls-client-x86.so:tls_client/dependencies'
116
+ ```
117
+
118
+ Linux Alpine / AMD64:
119
+ ```
120
+ --add-binary '{path_to_library}/tls_client/dependencies/tls-client-amd64.so:tls_client/dependencies'
121
+ ```
122
+
123
+ MacOS M1 and older:
124
+ ```
125
+ --add-binary '{path_to_library}/tls_client/dependencies/tls-client-x86.dylib:tls_client/dependencies'
126
+ ```
127
+
128
+ MacOS M2:
129
+ ```
130
+ --add-binary '{path_to_library}/tls_client/dependencies/tls-client-arm64.dylib:tls_client/dependencies'
131
+ ```
132
+
133
+ Windows:
134
+ ```
135
+ --add-binary '{path_to_library}/tls_client/dependencies/tls-client-64.dll;tls_client/dependencies'
136
+ ```
137
+
138
+ # Acknowledgements
139
+ Big shout out to [Bogdanfinn](https://github.com/bogdanfinn) for open sourcing his [tls-client](https://github.com/bogdanfinn/tls-client) in Golang.
140
+ Also I wanted to keep the syntax as similar as possible to [requests](https://github.com/psf/requests), as most people use it and are familiar with it!
141
+
142
+ # Changelog
143
+
144
+ ## 1.0.2
145
+ - **Fix**: binary response bodies (protobuf, images, ...) were corrupted by a
146
+ UTF-8 `byteReplacer` (U+FFFD) inside the Go C library. Every byte > 127 that
147
+ did not form a valid UTF-8 sequence was replaced by `EF BF BD`.
148
+ - `sessions.py`: now sends `isByteResponse: True` in the request payload so
149
+ the backend returns the body as a base64 data-URI.
150
+ - `response.py`: `build_response` decodes the data-URI back to raw bytes for
151
+ `Response.content`; `Response.text` is a UTF-8 view (with replacement
152
+ chars for invalid sequences).
153
+ - Added `tests/test_binary_response.py` (regression suite, needs network).
154
+
155
+ ## 1.0.1
156
+ - Certificate pinning
@@ -0,0 +1,50 @@
1
+ [build-system]
2
+ requires = ["setuptools>=68", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "python-tls-client"
7
+ dynamic = ["version"]
8
+ description = "Advanced Python HTTP Client with TLS fingerprint spoofing (fork with binary-response fix and certificate pinning)"
9
+ readme = "README.md"
10
+ license = "MIT"
11
+ authors = [
12
+ { name = "Emanuele Scarlata" }
13
+ ]
14
+ requires-python = ">=3.8"
15
+ dependencies = [
16
+ "typing-extensions",
17
+ ]
18
+ classifiers = [
19
+ "Environment :: Web Environment",
20
+ "Intended Audience :: Developers",
21
+ "Natural Language :: English",
22
+ "Operating System :: Unix",
23
+ "Operating System :: MacOS :: MacOS X",
24
+ "Operating System :: Microsoft :: Windows",
25
+ "Programming Language :: Python",
26
+ "Programming Language :: Python :: 3",
27
+ "Programming Language :: Python :: 3.8",
28
+ "Programming Language :: Python :: 3.9",
29
+ "Programming Language :: Python :: 3.10",
30
+ "Programming Language :: Python :: 3.11",
31
+ "Programming Language :: Python :: 3.12",
32
+ "Programming Language :: Python :: 3 :: Only",
33
+ "Topic :: Internet :: WWW/HTTP",
34
+ "Topic :: Software Development :: Libraries",
35
+ ]
36
+
37
+ [project.urls]
38
+ Homepage = "https://github.com/Fenix46/Python-Tls-Client"
39
+ Source = "https://github.com/Fenix46/Python-Tls-Client"
40
+ Original = "https://github.com/FlorianREGAZ/Python-Tls-Client"
41
+
42
+ [tool.setuptools]
43
+ packages = ["tls_client", "tls_client.dependencies"]
44
+ include-package-data = true
45
+
46
+ [tool.setuptools.dynamic]
47
+ version = { attr = "tls_client.__version__.__version__" }
48
+
49
+ [tool.setuptools.package-data]
50
+ "tls_client.dependencies" = ["*"]
@@ -0,0 +1,187 @@
1
+ Metadata-Version: 2.4
2
+ Name: python-tls-client
3
+ Version: 1.0.2
4
+ Summary: Advanced Python HTTP Client with TLS fingerprint spoofing (fork with binary-response fix and certificate pinning)
5
+ Author: Emanuele Scarlata
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/Fenix46/Python-Tls-Client
8
+ Project-URL: Source, https://github.com/Fenix46/Python-Tls-Client
9
+ Project-URL: Original, https://github.com/FlorianREGAZ/Python-Tls-Client
10
+ Classifier: Environment :: Web Environment
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: Natural Language :: English
13
+ Classifier: Operating System :: Unix
14
+ Classifier: Operating System :: MacOS :: MacOS X
15
+ Classifier: Operating System :: Microsoft :: Windows
16
+ Classifier: Programming Language :: Python
17
+ Classifier: Programming Language :: Python :: 3
18
+ Classifier: Programming Language :: Python :: 3.8
19
+ Classifier: Programming Language :: Python :: 3.9
20
+ Classifier: Programming Language :: Python :: 3.10
21
+ Classifier: Programming Language :: Python :: 3.11
22
+ Classifier: Programming Language :: Python :: 3.12
23
+ Classifier: Programming Language :: Python :: 3 :: Only
24
+ Classifier: Topic :: Internet :: WWW/HTTP
25
+ Classifier: Topic :: Software Development :: Libraries
26
+ Requires-Python: >=3.8
27
+ Description-Content-Type: text/markdown
28
+ License-File: LICENSE
29
+ Requires-Dist: typing-extensions
30
+ Dynamic: license-file
31
+
32
+ # Python-TLS-Client
33
+
34
+ > **Nota:** questo è un fork di [Python-Tls-Client](https://github.com/FlorianREGAZ/Python-Tls-Client)
35
+ > di Florian Zager, pubblicato su PyPI con nome diverso (`python-tls-client`) perché
36
+ > il nome originale `tls-client` è già occupato dal progetto upstream.
37
+ > Il modulo importabile resta invariato: `import tls_client`.
38
+ >
39
+ > Modifiche rispetto all'originale:
40
+ > - Fix corruzione risposte binarie (protobuf, immagini, ...) — vedi Changelog 1.0.2
41
+ > - Certificate pinning (vedi Changelog 1.0.1)
42
+
43
+ Python-TLS-Client is an advanced HTTP library based on requests and tls-client.
44
+
45
+ # Installation
46
+ ```
47
+ pip install python-tls-client
48
+ ```
49
+
50
+ # Examples
51
+ The syntax is inspired by [requests](https://github.com/psf/requests), so its very similar and there are only very few things that are different.
52
+
53
+ Example 1 - Preset:
54
+ ```python
55
+ import tls_client
56
+
57
+ # You can also use the following as `client_identifier`:
58
+ # Chrome --> chrome_103, chrome_104, chrome_105, chrome_106, chrome_107, chrome_108, chrome109, Chrome110,
59
+ # chrome111, chrome112, chrome_116_PSK, chrome_116_PSK_PQ, chrome_117, chrome_120
60
+ # Firefox --> firefox_102, firefox_104, firefox108, Firefox110, firefox_117, firefox_120
61
+ # Opera --> opera_89, opera_90
62
+ # Safari --> safari_15_3, safari_15_6_1, safari_16_0
63
+ # iOS --> safari_ios_15_5, safari_ios_15_6, safari_ios_16_0
64
+ # iPadOS --> safari_ios_15_6
65
+ # Android --> okhttp4_android_7, okhttp4_android_8, okhttp4_android_9, okhttp4_android_10, okhttp4_android_11,
66
+ # okhttp4_android_12, okhttp4_android_13
67
+ #
68
+ # more client identifiers can be found in settings.py
69
+
70
+ session = tls_client.Session(
71
+ client_identifier="chrome112",
72
+ random_tls_extension_order=True
73
+ )
74
+
75
+ res = session.get(
76
+ "https://www.example.com/",
77
+ headers={
78
+ "key1": "value1",
79
+ },
80
+ proxy="http://user:password@host:port"
81
+ )
82
+ ```
83
+
84
+ Example 2 - Custom:
85
+ ```python
86
+ import tls_client
87
+
88
+ session = tls_client.Session(
89
+ ja3_string="771,4865-4866-4867-49195-49199-49196-49200-52393-52392-49171-49172-156-157-47-53,0-23-65281-10-11-35-16-5-13-18-51-45-43-27-17513,29-23-24,0",
90
+ h2_settings={
91
+ "HEADER_TABLE_SIZE": 65536,
92
+ "MAX_CONCURRENT_STREAMS": 1000,
93
+ "INITIAL_WINDOW_SIZE": 6291456,
94
+ "MAX_HEADER_LIST_SIZE": 262144
95
+ },
96
+ h2_settings_order=[
97
+ "HEADER_TABLE_SIZE",
98
+ "MAX_CONCURRENT_STREAMS",
99
+ "INITIAL_WINDOW_SIZE",
100
+ "MAX_HEADER_LIST_SIZE"
101
+ ],
102
+ supported_signature_algorithms=[
103
+ "ECDSAWithP256AndSHA256",
104
+ "PSSWithSHA256",
105
+ "PKCS1WithSHA256",
106
+ "ECDSAWithP384AndSHA384",
107
+ "PSSWithSHA384",
108
+ "PKCS1WithSHA384",
109
+ "PSSWithSHA512",
110
+ "PKCS1WithSHA512",
111
+ ],
112
+ supported_versions=["GREASE", "1.3", "1.2"],
113
+ key_share_curves=["GREASE", "X25519"],
114
+ cert_compression_algo="brotli",
115
+ pseudo_header_order=[
116
+ ":method",
117
+ ":authority",
118
+ ":scheme",
119
+ ":path"
120
+ ],
121
+ connection_flow=15663105,
122
+ header_order=[
123
+ "accept",
124
+ "user-agent",
125
+ "accept-encoding",
126
+ "accept-language"
127
+ ]
128
+ )
129
+
130
+ res = session.post(
131
+ "https://www.example.com/",
132
+ headers={
133
+ "key1": "value1",
134
+ },
135
+ json={
136
+ "key1": "key2"
137
+ }
138
+ )
139
+ ```
140
+
141
+ # Pyinstaller / Pyarmor
142
+ **If you want to pack the library with Pyinstaller or Pyarmor, make sure to add this to your command:**
143
+
144
+ Linux - Ubuntu / x86:
145
+ ```
146
+ --add-binary '{path_to_library}/tls_client/dependencies/tls-client-x86.so:tls_client/dependencies'
147
+ ```
148
+
149
+ Linux Alpine / AMD64:
150
+ ```
151
+ --add-binary '{path_to_library}/tls_client/dependencies/tls-client-amd64.so:tls_client/dependencies'
152
+ ```
153
+
154
+ MacOS M1 and older:
155
+ ```
156
+ --add-binary '{path_to_library}/tls_client/dependencies/tls-client-x86.dylib:tls_client/dependencies'
157
+ ```
158
+
159
+ MacOS M2:
160
+ ```
161
+ --add-binary '{path_to_library}/tls_client/dependencies/tls-client-arm64.dylib:tls_client/dependencies'
162
+ ```
163
+
164
+ Windows:
165
+ ```
166
+ --add-binary '{path_to_library}/tls_client/dependencies/tls-client-64.dll;tls_client/dependencies'
167
+ ```
168
+
169
+ # Acknowledgements
170
+ Big shout out to [Bogdanfinn](https://github.com/bogdanfinn) for open sourcing his [tls-client](https://github.com/bogdanfinn/tls-client) in Golang.
171
+ Also I wanted to keep the syntax as similar as possible to [requests](https://github.com/psf/requests), as most people use it and are familiar with it!
172
+
173
+ # Changelog
174
+
175
+ ## 1.0.2
176
+ - **Fix**: binary response bodies (protobuf, images, ...) were corrupted by a
177
+ UTF-8 `byteReplacer` (U+FFFD) inside the Go C library. Every byte > 127 that
178
+ did not form a valid UTF-8 sequence was replaced by `EF BF BD`.
179
+ - `sessions.py`: now sends `isByteResponse: True` in the request payload so
180
+ the backend returns the body as a base64 data-URI.
181
+ - `response.py`: `build_response` decodes the data-URI back to raw bytes for
182
+ `Response.content`; `Response.text` is a UTF-8 view (with replacement
183
+ chars for invalid sequences).
184
+ - Added `tests/test_binary_response.py` (regression suite, needs network).
185
+
186
+ ## 1.0.1
187
+ - Certificate pinning
@@ -0,0 +1,29 @@
1
+ LICENSE
2
+ MANIFEST.in
3
+ README.md
4
+ pyproject.toml
5
+ requirements.txt
6
+ setup.py
7
+ python_tls_client.egg-info/PKG-INFO
8
+ python_tls_client.egg-info/SOURCES.txt
9
+ python_tls_client.egg-info/dependency_links.txt
10
+ python_tls_client.egg-info/requires.txt
11
+ python_tls_client.egg-info/top_level.txt
12
+ tests/test_binary_response.py
13
+ tls_client/__init__.py
14
+ tls_client/__version__.py
15
+ tls_client/cffi.py
16
+ tls_client/cookies.py
17
+ tls_client/exceptions.py
18
+ tls_client/response.py
19
+ tls_client/sessions.py
20
+ tls_client/settings.py
21
+ tls_client/structures.py
22
+ tls_client/dependencies/__init__.py
23
+ tls_client/dependencies/tls-client-32.dll
24
+ tls_client/dependencies/tls-client-64.dll
25
+ tls_client/dependencies/tls-client-amd64.so
26
+ tls_client/dependencies/tls-client-arm64.dylib
27
+ tls_client/dependencies/tls-client-arm64.so
28
+ tls_client/dependencies/tls-client-x86.dylib
29
+ tls_client/dependencies/tls-client-x86.so
@@ -0,0 +1 @@
1
+ typing-extensions
@@ -0,0 +1 @@
1
+ typing-extensions
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env python
2
+ from setuptools import setup
3
+
4
+ setup()