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.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.35.0

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.35.0
File Actions
lucky_tls-0.35.0-cp314-cp314-win_amd64.whl CPython 3.14 CPython 3.14 Windows x86-64 Details for lucky_tls-0.35.0-cp314-cp314-win_amd64.whl
lucky_tls-0.35.0-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.35.0-cp314-cp314-manylinux_2_28_x86_64.whl
lucky_tls-0.35.0-cp313-cp313-win_amd64.whl CPython 3.13 CPython 3.13 Windows x86-64 Details for lucky_tls-0.35.0-cp313-cp313-win_amd64.whl
lucky_tls-0.35.0-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.35.0-cp313-cp313-manylinux_2_28_x86_64.whl
lucky_tls-0.35.0-cp312-cp312-win_amd64.whl CPython 3.12 CPython 3.12 Windows x86-64 Details for lucky_tls-0.35.0-cp312-cp312-win_amd64.whl
lucky_tls-0.35.0-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.35.0-cp312-cp312-manylinux_2_28_x86_64.whl
lucky_tls-0.35.0-cp311-cp311-win_amd64.whl CPython 3.11 CPython 3.11 Windows x86-64 Details for lucky_tls-0.35.0-cp311-cp311-win_amd64.whl
lucky_tls-0.35.0-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.35.0-cp311-cp311-manylinux_2_28_x86_64.whl

Total release size: 34.8 MB

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

Download URL lucky_tls-0.35.0-cp314-cp314-win_amd64.whl
Size 4.1 MB
Tags CPython 3.14 Windows x86-64
SHA-256 checksum
How to use checksums
f15e93399643cc7ce7a66f92be50966ce7f82faaf8159a94cfd682c166e653f0
BLAKE2b-256 checksum
How to use checksums
1fc40902181ff9650372a8e11598e7f94311eaaed9d4721eef4e504d6bcfdb5f
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.35.0-cp314-cp314-manylinux_2_28_x86_64.whl

Download URL lucky_tls-0.35.0-cp314-cp314-manylinux_2_28_x86_64.whl
Size 4.6 MB
Tags CPython 3.14 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
c3316ff7a66a112fb80dfbd3d5cd0aac756f107344ef2da0d84f710a97f2b80b
BLAKE2b-256 checksum
How to use checksums
1a395fd414b62eeaa051b7ad704fca9a7bbe5a32816015913d0a7547d5f15274
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.35.0-cp313-cp313-win_amd64.whl

Download URL lucky_tls-0.35.0-cp313-cp313-win_amd64.whl
Size 4.0 MB
Tags CPython 3.13 Windows x86-64
SHA-256 checksum
How to use checksums
13cfbadf0e86428af9d073154da86a44ea29a963cbf0e7db43cc20f37c82f8fd
BLAKE2b-256 checksum
How to use checksums
91cd24d3130cf1fcbe8080be0d810d36e1ef8c4dbd2853103670769a007e7847
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.35.0-cp313-cp313-manylinux_2_28_x86_64.whl

Download URL lucky_tls-0.35.0-cp313-cp313-manylinux_2_28_x86_64.whl
Size 4.6 MB
Tags CPython 3.13 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
01f0d1ec81cef392bdc0d598475269889db839b3f69241fcba8fc638fdaf4107
BLAKE2b-256 checksum
How to use checksums
be0a8baea6f3841234832bb3a2ce25922d06f2822eb2a42bb75c7e8fc35816b9
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.35.0-cp312-cp312-win_amd64.whl

Download URL lucky_tls-0.35.0-cp312-cp312-win_amd64.whl
Size 4.0 MB
Tags CPython 3.12 Windows x86-64
SHA-256 checksum
How to use checksums
ff5355b866bcf19c43dfe492fedbab4ffc364785aa7cd2aa7219da18bf52dbf0
BLAKE2b-256 checksum
How to use checksums
8a820fdb2ffd34381e8aed389fe0183b0c1c283508804359faca6b7509c53111
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.35.0-cp312-cp312-manylinux_2_28_x86_64.whl

Download URL lucky_tls-0.35.0-cp312-cp312-manylinux_2_28_x86_64.whl
Size 4.7 MB
Tags CPython 3.12 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
a923b51be6410536995663d9974ba5728aa1f7d840cd69bd5f0146a7c4ce0098
BLAKE2b-256 checksum
How to use checksums
cc171d8ff403df1374d3b0ef6fca9696bfa6f663180c367102c6b5b1d9e8ce1e
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.35.0-cp311-cp311-win_amd64.whl

Download URL lucky_tls-0.35.0-cp311-cp311-win_amd64.whl
Size 4.0 MB
Tags CPython 3.11 Windows x86-64
SHA-256 checksum
How to use checksums
7e825efc043e14d045d01d38688cbb32aedd651727ba65d935c14a017608ec2d
BLAKE2b-256 checksum
How to use checksums
b3b468af8587b0996a358a9ec3f6aca51fee5dec4e1ac4bc58aed7d894c50870
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.35.0-cp311-cp311-manylinux_2_28_x86_64.whl

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

Security for lucky-tls 0.35.0

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