Skip to main content

Python bindings for Specter, a Chrome-accurate HTTP client with TLS, HTTP/1.1, HTTP/2, HTTP/3, and WebSocket fingerprinting. Improved TTFT and TPS for LLMs.

Project description

Specter

Python bindings for the Specter HTTP client with TLS, HTTP/2, HTTP/3, RFC 6455 WebSocket, and RFC 8441 Extended CONNECT support.

Supported Chrome fingerprints are specter.FingerprintProfile.Chrome142 through specter.FingerprintProfile.Chrome148. Supported Firefox fingerprints are specter.FingerprintProfile.Firefox133 through specter.FingerprintProfile.Firefox151, plus ESR branches FirefoxEsr115, FirefoxEsr128, and FirefoxEsr140; examples use Chrome148, the latest implemented Chrome profile.

Installation

pip install specters

HTTP

Synchronous HTTP:

import specter

builder = specter.SyncClient.builder()
builder.fingerprint(specter.FingerprintProfile.Chrome148)
client = builder.build()

response = client.get("https://example.com/").send()
print(response.status)
print(response.text())

Async HTTP:

import specter

builder = specter.AsyncClient.builder()
builder.fingerprint(specter.FingerprintProfile.Chrome148)
client = builder.build()

response = await client.get("https://example.com/").send()
print(response.status)
print(response.text())

RFC 6455 WebSockets

import specter

builder = specter.Client.builder()
builder.cookie_store(True)
client = builder.build()

ws_builder = client.websocket("wss://example.com/socket")
ws_builder.subprotocol("chat.v1")
ws = await ws_builder.connect()

await ws.send_text("hello")
message = await ws.next()
await ws.close(specter.CloseFrame(specter.CLOSE_NORMAL, "done"))

RFC 8441 HTTP/2 Tunnels

import specter

builder = specter.Client.builder()
builder.http2_prior_knowledge(True)
client = builder.build()

tunnel = await client.websocket_h2("https://example.com/h2-tunnel").open()
await tunnel.send_bytes(b"raw bytes", end_stream=False)
data = await tunnel.recv_bytes()
await tunnel.close_send()

RFC 6455 framed WebSockets and RFC 8441 raw HTTP/2 tunnels are separate APIs by design.

License

MIT

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

specters-4.2.2.tar.gz (849.4 kB view details)

Uploaded Source

Built Distributions

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

specters-4.2.2-cp310-abi3-manylinux_2_28_x86_64.whl (11.5 MB view details)

Uploaded CPython 3.10+manylinux: glibc 2.28+ x86-64

specters-4.2.2-cp310-abi3-manylinux_2_28_aarch64.whl (10.7 MB view details)

Uploaded CPython 3.10+manylinux: glibc 2.28+ ARM64

specters-4.2.2-cp310-abi3-macosx_11_0_arm64.whl (3.1 MB view details)

Uploaded CPython 3.10+macOS 11.0+ ARM64

specters-4.2.2-cp310-abi3-macosx_10_13_x86_64.whl (3.3 MB view details)

Uploaded CPython 3.10+macOS 10.13+ x86-64

File details

Details for the file specters-4.2.2.tar.gz.

File metadata

  • Download URL: specters-4.2.2.tar.gz
  • Upload date:
  • Size: 849.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for specters-4.2.2.tar.gz
Algorithm Hash digest
SHA256 23082dad2241b10f6f8a3b75c12354dd6647c925f646db399cfd82b81269271a
MD5 2761bf6431fbff347bf0131e5b502368
BLAKE2b-256 06593f7309a1a236b0d62f94d1b0b82c6b49fd5111c5866d0b371a3832a6060a

See more details on using hashes here.

File details

Details for the file specters-4.2.2-cp310-abi3-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for specters-4.2.2-cp310-abi3-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 302fcac7187a91e10d520e3ec849b56767e684971d533e89e53259e1b2d6c28b
MD5 d791a4be50ad85ba49f52e5c3fe59714
BLAKE2b-256 d31b8fef10696c5c91f76ac9ca124e600839a8269a8c42e94b0f739b400f1080

See more details on using hashes here.

File details

Details for the file specters-4.2.2-cp310-abi3-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for specters-4.2.2-cp310-abi3-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 ec885f910288d24f429878e6017abe8992a53486d7923a84536f7c69e3781c7c
MD5 c1ae6da04832e8b89b5375894fd454fe
BLAKE2b-256 78bdf50360e33a5d46404501e31a59db4e638fdffc3ea0cc8026df972d260aa7

See more details on using hashes here.

File details

Details for the file specters-4.2.2-cp310-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for specters-4.2.2-cp310-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 fc4b994cf1bf7171263ce6b3f8c66120d6aa4cfae9e7ebfac94adf04729b4487
MD5 a117a4f7db0f92dc3b3045b9c2a98bd0
BLAKE2b-256 3a16a690b71739a72ca5911ac814b8df8904046e669decba8c97ff85e3b347b2

See more details on using hashes here.

File details

Details for the file specters-4.2.2-cp310-abi3-macosx_10_13_x86_64.whl.

File metadata

File hashes

Hashes for specters-4.2.2-cp310-abi3-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 7c38f40c5359332030f1d8e71e8cf0973b2352795f303dd67f8579319aef65f8
MD5 d8084385ed3da0d8183c90e5d9393144
BLAKE2b-256 a6971926313b7f66d68e7463b8e7bf840232060d26de26bb4785ba872f079cc5

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