Skip to main content

lucky_tls

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

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

安装

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

python -m pip install -U lucky_tls

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

使用

from lucky_tls import Session

with Session(profile="chrome156") as session:
    response = session.get("https://example.com/", timeout=10)
    print(response.status_code)
    print(response.text)

请求支持 params、json、data、cookies 和逐请求 timeout;默认跟随重定向,可通过 allow_redirects=False 关闭。使用 AsyncSession 发起异步请求。默认 profile 为 chrome153,可显式选择 chrome156。

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

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

Total release size: 34.7 MB

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

Download URL lucky_tls-0.34.0-cp314-cp314-win_amd64.whl
Size 4.1 MB
Tags CPython 3.14 Windows x86-64
SHA-256 checksum
How to use checksums
2d5fbbef308df4157703fd2ffb73405718e3ad068b3906a166f47f0545657dd7
BLAKE2b-256 checksum
How to use checksums
d2fdc9517f42f207fea3c9c4dc1c26f31bea6a65068df289c85cf0d34451bfc1
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.34.0-cp314-cp314-manylinux_2_28_x86_64.whl

Download URL lucky_tls-0.34.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
251214b4f02f556cd27cff6eff6cc9e73fd2d34c4ffee385f4bfd4c3d1690008
BLAKE2b-256 checksum
How to use checksums
ed7dc64b1c4c263ce17d51ca9da0d93280cc1444e6907f482604e57fbaa0f066
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.34.0-cp313-cp313-win_amd64.whl

Download URL lucky_tls-0.34.0-cp313-cp313-win_amd64.whl
Size 4.0 MB
Tags CPython 3.13 Windows x86-64
SHA-256 checksum
How to use checksums
e992f12171102177b2ad74568674ee26793e6f96c278a06725d72c915625bbfa
BLAKE2b-256 checksum
How to use checksums
cfdf67c5fbf3b89dc4d6956a52db09d8fbb778852724c1893d95408959ac75f8
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.34.0-cp313-cp313-manylinux_2_28_x86_64.whl

Download URL lucky_tls-0.34.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
636dcf7008a99a5f23112095a3acc75058f7d914766118d7f8e8957a250d4d92
BLAKE2b-256 checksum
How to use checksums
7f0357ac3689d705ea538ebd5bd36234f5c70f73b553fe6c83e4b4cd3180d602
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.34.0-cp312-cp312-win_amd64.whl

Download URL lucky_tls-0.34.0-cp312-cp312-win_amd64.whl
Size 4.0 MB
Tags CPython 3.12 Windows x86-64
SHA-256 checksum
How to use checksums
644d6803c01e0cfad49f2117edb4d6eee25ad9f11f3dfe4f73f8d9e8c6c82a17
BLAKE2b-256 checksum
How to use checksums
f43ed8c40de2b4d50e7a018bcefb0f87f310b67bd5bb371fe69faa64f74bd6e6
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.34.0-cp312-cp312-manylinux_2_28_x86_64.whl

Download URL lucky_tls-0.34.0-cp312-cp312-manylinux_2_28_x86_64.whl
Size 4.6 MB
Tags CPython 3.12 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
1157119637e86b19aec0cba71431fefa9d6092f96e5cda625da8f75320b5bb62
BLAKE2b-256 checksum
How to use checksums
c55e11ff7b2b8a7d88e6ca636b5c06522e5373ef1343be5f427b51db2b28c488
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.34.0-cp311-cp311-win_amd64.whl

Download URL lucky_tls-0.34.0-cp311-cp311-win_amd64.whl
Size 4.0 MB
Tags CPython 3.11 Windows x86-64
SHA-256 checksum
How to use checksums
a0ec1d69959ce812ce23a8ebf6638c364418930ee62f8e84d4d6e3bc7806232e
BLAKE2b-256 checksum
How to use checksums
8a2cadf086d41b1160bf8bd46ee36018386b37409002ff28864c05446d1f1679
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.34.0-cp311-cp311-manylinux_2_28_x86_64.whl

Download URL lucky_tls-0.34.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
29d47dc18eee1b0688164c4218487ed33999945f0dd1d33c6a59ff35f2a80da5
BLAKE2b-256 checksum
How to use checksums
5a24bd6a01c69a07d3bf78bce8a34c092844ec9c0e663c4fa256ca1313c3413e
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.34.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