Skip to main content

lucky_tls

供 Python 调用的 TLS/HTTPS 请求库,支持同步、异步请求及 Chrome153/156/157、Edge157 配置,默认使用 Edge157。

仅限个人和非商业用途,不允许商用。 采用专有二进制使用许可,不是开源软件;仅授予安装、运行和调用接口的权利,不授予修改、再分发、转售或源码获取权。完整条款随安装包提供,第三方组件适用各自的许可证。

安装

在具有匹配二进制 wheel 的 Python 环境中执行:

python -m pip install -U lucky_tls

PyPI 将下划线与连字符归一化,lucky_tls 和 lucky-tls 指向同一个项目。 仅提供已构建平台的二进制 wheel,不提供源码安装包。没有匹配 wheel 的环境无法直接安装。 支持 Windows x64,以及 glibc 2.28 及以上的 Linux x86_64;对应标准 CPython 3.11、3.12、3.13 和 3.14。不支持 free-threaded Python、Linux ARM64 或 Alpine/musl。

使用

from lucky_tls import Session

with Session() as session:  # 默认 edge157
    response = session.get("https://example.com/", timeout=10)
    print(response)  # <Response [200]>
    print(response.text)

请求支持 params、json、data、cookies 和逐请求 timeout;默认跟随重定向,可通过 allow_redirects=False 关闭。使用 AsyncSession 发起异步请求。默认 profile 为 edge157,可在 Session 或单次请求上显式选择 chrome153、chrome156、chrome157、edge157 或基础配置 default。

接口类型提示随 wheel 提供。浏览器配置的字段匹配不代表完整浏览器等价。

0.36.1:更新 Chrome157 / Edge157 采集基准

已对照 Windows Chrome 157.0.8103.80 和 Edge 157.0.4341.60:导航、fetch GET、fetch POST 各重复 3 次,18 次对照全部通过。与原有 157 配置相比,本次补丁构建的 TLS 扩展载荷、JA4、HTTP/2、场景请求头顺序和 HPACK 编码未发现差异,因此保留协议模板及 JA3 扩展顺序随机化。默认仍为 edge157,也可使用 profile="chrome157"。

验证范围是全新 Windows 配置、关闭 field trials 的 TLS 1.3 / HTTP/2 请求,不代表所有浏览器实验、站点或 HTTP/3 的完整等价。

0.36.0:证书验证、流量统计和类型化异常

新增 verify,Session 与模块级请求默认 True。单次请求省略或传 None 继承 Session;False 关闭证书链和主机名验证;字符串指定 PEM CA 文件。请求级 True 可重新开启验证,并保留 Session 的自定义 CA。支持同步、两种异步后端、流式和 HTTP/3,连接与会话票据按验证配置隔离。

from lucky_tls import Session

with Session(verify=True, traffic=True) as session:
    response = session.get("https://example.com/", timeout=10)
    print(response)                # <Response [200]>
    print(response.traffic.total)  # 本次请求流量

traffic 默认关闭;开启后通过 resp.traffic 查看统计。新增 ProtocolError、TooManyRedirects、ConnectionClosed 等异常,保留原有内建异常继承关系。修复 Vary 缓存变体、异常响应头解析、失效连接恢复以及 DNS/上传线程池阻塞问题。默认 profile 继续为 edge157。

0.35.0:Edge157 默认与对应版本请求头

新增 Chrome157 和 Edge157 预设,默认采用 Edge157。自动 User-Agent、Client Hints 等请求头随有效 profile 切换,用户显式 headers 优先,普通请求保留 Accept: */*。导航与 fetch 场景可使用 BrowserContext,或显式使用 chrome157_headers() / edge157_headers()。原始 JA3 继续随浏览器扩展乱序变化。

print(resp) 与 curl_cffi 一样只显示 <Response [状态码]>;详细信息使用 resp.status_code、resp.text、resp.content、resp.json()、resp.headers、resp.cookies.get_dict() 等获取。同步、异步及流式响应均使用简短打印,打印不会消费流式正文。

Chrome 157.0.8103.51 与 Edge 157.0.4341.42 的 Windows 首次 TLS1.3/HTTP2 导航及同源 fetch 样本已完成对照。HTTP3 支持功能请求,但本轮未完成 157 浏览器 QUIC/HTTP3 指纹的完整对照。

0.34.1:默认 Accept 请求头

普通请求默认发送 Accept: */*,支持同步接口和两种异步后端。请求级或 Session 级自定义 Accept 优先;headers={"Accept": None} 可抑制默认值,空字符串保留为空值。修复重定向与异步 worker 间的删除标记传递。显式浏览器上下文仍使用页面策略生成请求头。

from lucky_tls import BrowserContext, Session

context = BrowserContext.fetch("https://example.com/page")
with Session(profile="chrome156", browser_context=context) as session:
    response = session.get("https://example.com/", timeout=10)
    print(response.status_code, response.from_cache)

显式提供上下文后启用分区 HTTP 缓存、ETag/304 验证、SameSite/CHIPS Cookie、Origin/Referer/Sec-Fetch 和 CORS 预检。BrowserContext.fetch 的 credentials 可选 omit、same-origin、include;cache 可选 default、no-store、reload、no-cache、force-cache、only-if-cached,最后一种要求 mode="same-origin"。单次请求可以用 context= 覆盖 Session 默认上下文。

手动设置浏览器 Cookie 使用 session.cookies.set("name", "value", url="https://example.com/", same_site="Lax");上下文模式不接受没有 URL 作用域的 Cookie 字典或手写 Cookie 请求头。fetch 响应隐藏 Set-Cookie,已接受的 Cookie 保存在 session.cookies。跨源 CORS 拒绝会抛 BrowserPolicyError,no-cors 的 opaque 响应不会暴露正文。普通不带上下文的请求保留原有行为。

AsyncSession 的 threaded 与 native 后端支持同样的页面策略。上下文目前要求 stream=False,缓存只覆盖内存中的完整 GET;allow_redirects=False 是 requests 风格停止跳转,不是 Fetch manual redirect。调用者需要提供正确的页面与顶层站点,运行库不会启动或执行浏览器页面。

本版同时完善 QUIC 会话恢复、ECH 扩展压缩和 QPACK。HTTP/3 需显式选择;不实现 QUIC 0-RTT、自动 DNS HTTPS/Alt-Svc 选择、DOM、Service Worker 或完整浏览器行为。

Metadata

Release files for lucky-tls 0.36.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distributions (wheels)

Table of built distributions (wheels) for lucky-tls 0.36.1
File Actions
lucky_tls-0.36.1-cp314-cp314-win_amd64.whl CPython 3.14 CPython 3.14 Windows x86-64 Details for lucky_tls-0.36.1-cp314-cp314-win_amd64.whl
lucky_tls-0.36.1-cp314-cp314-manylinux_2_28_x86_64.whl CPython 3.14 CPython 3.14 Linux glibc 2.28+ x86-64 Details for lucky_tls-0.36.1-cp314-cp314-manylinux_2_28_x86_64.whl
lucky_tls-0.36.1-cp314-cp314-macosx_11_0_x86_64.whl CPython 3.14 CPython 3.14 macOS 11.0+ x86-64 Details for lucky_tls-0.36.1-cp314-cp314-macosx_11_0_x86_64.whl
lucky_tls-0.36.1-cp314-cp314-macosx_11_0_arm64.whl CPython 3.14 CPython 3.14 macOS 11.0+ ARM64 Details for lucky_tls-0.36.1-cp314-cp314-macosx_11_0_arm64.whl
lucky_tls-0.36.1-cp313-cp313-win_amd64.whl CPython 3.13 CPython 3.13 Windows x86-64 Details for lucky_tls-0.36.1-cp313-cp313-win_amd64.whl
lucky_tls-0.36.1-cp313-cp313-manylinux_2_28_x86_64.whl CPython 3.13 CPython 3.13 Linux glibc 2.28+ x86-64 Details for lucky_tls-0.36.1-cp313-cp313-manylinux_2_28_x86_64.whl
lucky_tls-0.36.1-cp313-cp313-macosx_11_0_x86_64.whl CPython 3.13 CPython 3.13 macOS 11.0+ x86-64 Details for lucky_tls-0.36.1-cp313-cp313-macosx_11_0_x86_64.whl
lucky_tls-0.36.1-cp313-cp313-macosx_11_0_arm64.whl CPython 3.13 CPython 3.13 macOS 11.0+ ARM64 Details for lucky_tls-0.36.1-cp313-cp313-macosx_11_0_arm64.whl
lucky_tls-0.36.1-cp312-cp312-win_amd64.whl CPython 3.12 CPython 3.12 Windows x86-64 Details for lucky_tls-0.36.1-cp312-cp312-win_amd64.whl
lucky_tls-0.36.1-cp312-cp312-manylinux_2_28_x86_64.whl CPython 3.12 CPython 3.12 Linux glibc 2.28+ x86-64 Details for lucky_tls-0.36.1-cp312-cp312-manylinux_2_28_x86_64.whl
lucky_tls-0.36.1-cp312-cp312-macosx_11_0_x86_64.whl CPython 3.12 CPython 3.12 macOS 11.0+ x86-64 Details for lucky_tls-0.36.1-cp312-cp312-macosx_11_0_x86_64.whl
lucky_tls-0.36.1-cp312-cp312-macosx_11_0_arm64.whl CPython 3.12 CPython 3.12 macOS 11.0+ ARM64 Details for lucky_tls-0.36.1-cp312-cp312-macosx_11_0_arm64.whl
lucky_tls-0.36.1-cp311-cp311-win_amd64.whl CPython 3.11 CPython 3.11 Windows x86-64 Details for lucky_tls-0.36.1-cp311-cp311-win_amd64.whl
lucky_tls-0.36.1-cp311-cp311-manylinux_2_28_x86_64.whl CPython 3.11 CPython 3.11 Linux glibc 2.28+ x86-64 Details for lucky_tls-0.36.1-cp311-cp311-manylinux_2_28_x86_64.whl
lucky_tls-0.36.1-cp311-cp311-macosx_11_0_x86_64.whl CPython 3.11 CPython 3.11 macOS 11.0+ x86-64 Details for lucky_tls-0.36.1-cp311-cp311-macosx_11_0_x86_64.whl
lucky_tls-0.36.1-cp311-cp311-macosx_11_0_arm64.whl CPython 3.11 CPython 3.11 macOS 11.0+ ARM64 Details for lucky_tls-0.36.1-cp311-cp311-macosx_11_0_arm64.whl

Total release size: 75.8 MB

Release files / lucky_tls-0.36.1-cp314-cp314-win_amd64.whl

Download URL lucky_tls-0.36.1-cp314-cp314-win_amd64.whl
Size 4.2 MB
Tags CPython 3.14 Windows x86-64
SHA-256 checksum
How to use checksums
f6cb3ce439bb1bf204b752be935c33d3c5033330eb792ca2d96b1e29b3c8287a
BLAKE2b-256 checksum
How to use checksums
72f02c2ae3eb6050936a83342d03706cd098a204b7e2edb82901b38ca830f037
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / lucky_tls-0.36.1-cp314-cp314-manylinux_2_28_x86_64.whl

Download URL lucky_tls-0.36.1-cp314-cp314-manylinux_2_28_x86_64.whl
Size 4.8 MB
Tags CPython 3.14 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
c53becdf5e2d9e86d4b7c8d8b1fa5ee7d70039e9d2ae6ea66f81722c73fc62c4
BLAKE2b-256 checksum
How to use checksums
d8ec33e8631b36ace292c13c1627dbeec3a831443d22eed21612416329fc4d4b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / lucky_tls-0.36.1-cp314-cp314-macosx_11_0_x86_64.whl

Download URL lucky_tls-0.36.1-cp314-cp314-macosx_11_0_x86_64.whl
Size 5.2 MB
Tags CPython 3.14 macOS 11.0+ x86-64
SHA-256 checksum
How to use checksums
7a138e1a41c1ed5275426ac4714156df176209ff6f5567854b44edc663b740b6
BLAKE2b-256 checksum
How to use checksums
11727766d4ed208840f6ec997e08398360902536264b350e41001db210ad53fa
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.5

Release files / lucky_tls-0.36.1-cp314-cp314-macosx_11_0_arm64.whl

Download URL lucky_tls-0.36.1-cp314-cp314-macosx_11_0_arm64.whl
Size 4.9 MB
Tags CPython 3.14 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
8971b8d1bc7efdbffa18b4e9b5cb82cb08518c00f49c10b7090a4a522a4a188b
BLAKE2b-256 checksum
How to use checksums
1b2ad4d42e8ba3ef81ffe15b1a13a0b9515bda526210a2296fa5055098dfd37c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.5

Release files / lucky_tls-0.36.1-cp313-cp313-win_amd64.whl

Download URL lucky_tls-0.36.1-cp313-cp313-win_amd64.whl
Size 4.1 MB
Tags CPython 3.13 Windows x86-64
SHA-256 checksum
How to use checksums
d148fc7c2e7eec3ea2e71ff5a53eb5d58ea1d524c89a2f2a5dcd0bc9f46bd97c
BLAKE2b-256 checksum
How to use checksums
8604197180aeac23db93ea03a9ee729c237c5f4494b3026fb189003b3d96667f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / lucky_tls-0.36.1-cp313-cp313-manylinux_2_28_x86_64.whl

Download URL lucky_tls-0.36.1-cp313-cp313-manylinux_2_28_x86_64.whl
Size 4.8 MB
Tags CPython 3.13 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
d2f843fb6383dfcd6be500fa02db5d9eb578a461d23ecd886ebba5e702f893d0
BLAKE2b-256 checksum
How to use checksums
51178216526ee6ca1fe0b8b3396203c8594d69d735a7c8d3d71dcc138491d061
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / lucky_tls-0.36.1-cp313-cp313-macosx_11_0_x86_64.whl

Download URL lucky_tls-0.36.1-cp313-cp313-macosx_11_0_x86_64.whl
Size 5.2 MB
Tags CPython 3.13 macOS 11.0+ x86-64
SHA-256 checksum
How to use checksums
3c46d3c213461e3a948412ebd60b04f031119147837937b363778e80bf87197b
BLAKE2b-256 checksum
How to use checksums
2f8e4bab0224a091d1590aa0907846417309350f36bfcb56981964f468ad0a3b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.5

Release files / lucky_tls-0.36.1-cp313-cp313-macosx_11_0_arm64.whl

Download URL lucky_tls-0.36.1-cp313-cp313-macosx_11_0_arm64.whl
Size 4.9 MB
Tags CPython 3.13 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
964deaa951a679df1ce63ab21154a4d6221efe941040e73dce7e92a7bf7d852d
BLAKE2b-256 checksum
How to use checksums
13129cc728964ff00dbd8c64adb17e3bc96d797f8a2ddb01cdb49f4a8d4cc796
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.5

Release files / lucky_tls-0.36.1-cp312-cp312-win_amd64.whl

Download URL lucky_tls-0.36.1-cp312-cp312-win_amd64.whl
Size 4.1 MB
Tags CPython 3.12 Windows x86-64
SHA-256 checksum
How to use checksums
6eb7be489124369bc7ce1eaf301a809c26f33e79e8ef5e890062ed22d2c0cf3f
BLAKE2b-256 checksum
How to use checksums
864973402ecbb597ee15e473acadc782dd6b5958cdd482b6cd146d97701d3352
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / lucky_tls-0.36.1-cp312-cp312-manylinux_2_28_x86_64.whl

Download URL lucky_tls-0.36.1-cp312-cp312-manylinux_2_28_x86_64.whl
Size 4.8 MB
Tags CPython 3.12 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
e5dcc746962ded6f2cc60b49ae7c26d9d6c99363860707745edd4d5224d27b2c
BLAKE2b-256 checksum
How to use checksums
f89660a3820723819369c2fa4fafb3e3cb4f53c7fa0b504b53506e8b9d01d3bc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / lucky_tls-0.36.1-cp312-cp312-macosx_11_0_x86_64.whl

Download URL lucky_tls-0.36.1-cp312-cp312-macosx_11_0_x86_64.whl
Size 5.2 MB
Tags CPython 3.12 macOS 11.0+ x86-64
SHA-256 checksum
How to use checksums
b7e84911e60ed9a742402dfd7778b22d0af4ce286d2a18d34638d29be855eff7
BLAKE2b-256 checksum
How to use checksums
a9441dcad693668f5901be800442687a27676c45f475fb285a58bf95da93c7c8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.5

Release files / lucky_tls-0.36.1-cp312-cp312-macosx_11_0_arm64.whl

Download URL lucky_tls-0.36.1-cp312-cp312-macosx_11_0_arm64.whl
Size 4.9 MB
Tags CPython 3.12 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
7d05570363efc5b6a71c0f2a1819279d1ba778c458e1d59524d4e48ead8f3681
BLAKE2b-256 checksum
How to use checksums
ee12fc7ae2a3beaecb2209521554c96e3ba54725af3fbb47a8add263b421f8e6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.5

Release files / lucky_tls-0.36.1-cp311-cp311-win_amd64.whl

Download URL lucky_tls-0.36.1-cp311-cp311-win_amd64.whl
Size 4.1 MB
Tags CPython 3.11 Windows x86-64
SHA-256 checksum
How to use checksums
a7858f8c7942a528a885dc3a13cd6c42c8f1b306f73508fd4142be76436c54d3
BLAKE2b-256 checksum
How to use checksums
e4741e78a94a6caf5e630b8eb2c5e0fe98b9e52cef2eaa83400141b3892854f5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / lucky_tls-0.36.1-cp311-cp311-manylinux_2_28_x86_64.whl

Download URL lucky_tls-0.36.1-cp311-cp311-manylinux_2_28_x86_64.whl
Size 4.9 MB
Tags CPython 3.11 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
e29b4868414091b47e7bb8baeaea8225ba345f01ff8869a4df82a9e9f53acfd4
BLAKE2b-256 checksum
How to use checksums
ab8838fc9d1df05569e55005f43473b660ca5828ac242725a5528395fc720bcd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / lucky_tls-0.36.1-cp311-cp311-macosx_11_0_x86_64.whl

Download URL lucky_tls-0.36.1-cp311-cp311-macosx_11_0_x86_64.whl
Size 4.9 MB
Tags CPython 3.11 macOS 11.0+ x86-64
SHA-256 checksum
How to use checksums
7c074916efd3d7de17c63a0d0be9a06f1726304c30247920fa40cd54ae0bf28b
BLAKE2b-256 checksum
How to use checksums
455882ca9601f1ca90488e222d3e0a30e54a4d2466f3732167d4786fe5edd290
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.5

Release files / lucky_tls-0.36.1-cp311-cp311-macosx_11_0_arm64.whl

Download URL lucky_tls-0.36.1-cp311-cp311-macosx_11_0_arm64.whl
Size 4.6 MB
Tags CPython 3.11 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
ebd6c6928a15bd8427d488d1928a943a5b36e4fafddb65af9ac3552a6dc2137d
BLAKE2b-256 checksum
How to use checksums
305caf615ca0cef2c71731c22d2dfe61b811ca38416ae9439a4779f1ecb84fe6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.5

Security for lucky-tls 0.36.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page