Skip to main content

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 git+https://github.com/999Samurai/tls-client.git

Disclaimer

This is a fork of FlorianREGAZ tls-client.

I created this fork because in the original repository the binaries were not updated and bugs remained open for too long.

Examples

The syntax is inspired by requests, so its very similar and there 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, chrome_106, chrome_107, chrome_108, chrome109, Chrome110,

#            chrome111, chrome112, chrome_116_PSK, chrome_116_PSK_PQ, chrome_117, chrome_120

# Firefox --> firefox_102, firefox_104, firefox108, Firefox110, firefox_117, firefox_120

# 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

# Android --> okhttp4_android_7, okhttp4_android_8, okhttp4_android_9, okhttp4_android_10, okhttp4_android_11,

#             okhttp4_android_12, okhttp4_android_13

#

# more client identifiers can be found in settings.py



session = tls_client.Session(

    client_identifier="chrome112",

    random_tls_extension_order=True

)



res = session.get(

    "https://www.example.com/",

    headers={

        "key1": "value1",

    },

    proxy="http://user:password@host:port"

)

Example 2 - Custom:

import tls_client



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={

        "HEADER_TABLE_SIZE": 65536,

        "MAX_CONCURRENT_STREAMS": 1000,

        "INITIAL_WINDOW_SIZE": 6291456,

        "MAX_HEADER_LIST_SIZE": 262144

    },

    h2_settings_order=[

        "HEADER_TABLE_SIZE",

        "MAX_CONCURRENT_STREAMS",

        "INITIAL_WINDOW_SIZE",

        "MAX_HEADER_LIST_SIZE"

    ],

    supported_signature_algorithms=[

        "ECDSAWithP256AndSHA256",

        "PSSWithSHA256",

        "PKCS1WithSHA256",

        "ECDSAWithP384AndSHA384",

        "PSSWithSHA384",

        "PKCS1WithSHA384",

        "PSSWithSHA512",

        "PKCS1WithSHA512",

    ],

    supported_versions=["GREASE", "1.3", "1.2"],

    key_share_curves=["GREASE", "X25519"],

    cert_compression_algo="brotli",

    pseudo_header_order=[

        ":method",

        ":authority",

        ":scheme",

        ":path"

    ],

    connection_flow=15663105,

    header_order=[

        "accept",

        "user-agent",

        "accept-encoding",

        "accept-language"

    ]

)



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-64.dll;tls_client/dependencies'

Acknowledgements

Big shout out to Bogdanfinn for open sourcing his tls-client in Golang.

Also I wanted to keep the syntax as similar as possible to requests, as most people use it and are familiar with it!

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

999tls_client-1.0.1.tar.gz (36.4 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

999tls_client-1.0.1-py3-none-any.whl (36.5 MB view details)

Uploaded Python 3

File details

Details for the file 999tls_client-1.0.1.tar.gz.

File metadata

  • Download URL: 999tls_client-1.0.1.tar.gz
  • Upload date:
  • Size: 36.4 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.12

File hashes

Hashes for 999tls_client-1.0.1.tar.gz
Algorithm Hash digest
SHA256 cf0f9b1da78f0af80f3a70a354f4297bffc4f046ea0386ed2fdf3f70f1761060
MD5 e4330ce67b7804e8838fd45bcb22dcee
BLAKE2b-256 613cdbba785f85df50d84e46acb4637abe560505aee411b0fb65cb80161df65d

See more details on using hashes here.

File details

Details for the file 999tls_client-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: 999tls_client-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 36.5 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.12

File hashes

Hashes for 999tls_client-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 6b750cc0648305d563e68cef79abfa6958227f57d4e1b08aa41fa32f9791e1aa
MD5 9f0899a3ce563b592c4a9d3029ee9cbf
BLAKE2b-256 66c5c07066b440f21c65e08c61fa18fe55a5b5de802d7c1deb838c6e8529bd98

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page