Advanced Python HTTP Client.
Project description
Python-TLS-Client
Python-TLS-Client is an advanced HTTP library based on requests and tls-client.
Installation
pip install tls-client
Examples
The syntax is insprired from requests, so its very similar and their are only very few things that are different.
Example 1 - Preset:
import tls_client
# You can also use the following as `client_identifier`:
# Chrome --> chrome_103, chrome_104, chrome_105
# Firefox --> firefox_102, firefox_104
# Opera --> opera_89, opera_90
# Safari --> safari_15_3, safari_15_6_1, safari_16_0
# iOS --> safari_ios_15_5, safari_ios_15_6, safari_ios_16_0
# iPadOS --> safari_ios_15_6
session = tls_client.Session(
client_identifier="chrome_105"
)
res = session.get(
"https://www.example.com/",
headers={
"key1": "value1",
},
proxy="http://user:password@host:port"
)
Example 2 - Custom:
import tls_client
# You can find more details about the arguments in `session.py` e.g. what 1, 2, 3, 4 etc. represents in h2_settings
session = tls_client.Session(
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",
h2_settings={
1: 65536,
3: 1000,
4: 6291456,
6: 262144
},
h2_settings_order=[
1,
3,
4,
6
],
pseudo_header_order=[
":method",
":authority",
":scheme",
":path"
],
connection_flow=15663105
)
res = session.post(
"https://www.example.com/",
headers={
"key1": "value1",
},
json={
"key1": "key2"
}
)
Pyinstaller / Pyarmor
If you want to pack the library with Pyinstaller or Pyarmor, make sure to add this to your command:
Linux - Ubuntu / x86:
--add-binary '{path_to_library}/tls_client/dependencies/tls-client-x86.so:tls_client/dependencies'
Linux Alpine / AMD64:
--add-binary '{path_to_library}/tls_client/dependencies/tls-client-amd64.so:tls_client/dependencies'
MacOS M1 and older:
--add-binary '{path_to_library}/tls_client/dependencies/tls-client-x86.dylib:tls_client/dependencies'
MacOS M2:
--add-binary '{path_to_library}/tls_client/dependencies/tls-client-arm64.dylib:tls_client/dependencies'
Windows:
--add-binary '{path_to_library}/tls_client/dependencies/tls-client.dll;tls_client/dependencies'
Acknowledgements
Big shout out to Bogdanfinn for open sourcing his tls-client in Golang.
Also to requests, as most of the cookie handling is copied from it. :'D
I wanted to keep the syntax as similar as possible to requests, as most people use it and are familiar with it!
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for tls_client-0.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | eadaff5607f1d852debd5b4a1601b83c24ec874d6280443a20d99699dcadecd3 |
|
MD5 | a094040821b5ba20ce81c8761b5e3d55 |
|
BLAKE2b-256 | 80e730fbc59f537e4566878560332ed091a1a40cdae386d406f1f948f2d88e26 |