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,以及 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(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 提供。浏览器配置的字段匹配不代表完整浏览器等价。
0.34.1:默认 Accept 请求头
普通请求默认发送 Accept: */*,支持同步接口和两种异步后端。请求级或 Session 级自定义 Accept 优先;headers={"Accept": None} 可抑制默认值,空字符串保留为空值。修复重定向与异步 worker 间的删除标记传递。显式浏览器上下文仍使用页面策略生成请求头。
0.34.0:页面上下文、缓存与 Cookie 策略
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.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distributions (wheels)
Total release size: 34.7 MB
Release files / lucky_tls-0.34.1-cp314-cp314-win_amd64.whl
| Download URL | lucky_tls-0.34.1-cp314-cp314-win_amd64.whl |
|---|---|
| Size | 4.1 MB |
| Tags | CPython 3.14 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
9af93fe892bd71708bfca9943c51fc31c5020de5dadba4eeb52914b500d41af6
|
|
BLAKE2b-256 checksum How to use checksums |
1a368ee772d72790197fa6eace11aac2d82d1749a67209189aef313a241fa925
|
| 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.1-cp314-cp314-manylinux_2_28_x86_64.whl
| Download URL | lucky_tls-0.34.1-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 |
102cce421502159c00079db44b2b1a2f2ea2d07714c7a435b4c9044596faf5af
|
|
BLAKE2b-256 checksum How to use checksums |
6307b2d01efd6f3ceda4730f3198a99866654f95b2fb03342ba124984e624034
|
| 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.1-cp313-cp313-win_amd64.whl
| Download URL | lucky_tls-0.34.1-cp313-cp313-win_amd64.whl |
|---|---|
| Size | 4.0 MB |
| Tags | CPython 3.13 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
06ef81472b15aa119874456ebf64943dfb8e278b3cc02b2760ed110dbecfb49b
|
|
BLAKE2b-256 checksum How to use checksums |
30a6ad8596d8e28061fc62ae600563d8c7c2cee1ac263312ab0409fdf3be62a6
|
| 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.1-cp313-cp313-manylinux_2_28_x86_64.whl
| Download URL | lucky_tls-0.34.1-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 |
7df45550a6efcd860ecca3e41170dcc474c346311176d3e09595a734e1a93faf
|
|
BLAKE2b-256 checksum How to use checksums |
8ae3a4db447706b5a89222c5c38eff5df895e2db551c860af779e10dc735004c
|
| 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.1-cp312-cp312-win_amd64.whl
| Download URL | lucky_tls-0.34.1-cp312-cp312-win_amd64.whl |
|---|---|
| Size | 4.0 MB |
| Tags | CPython 3.12 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
5249dc43d36d37d4dd2b2b56ceae84b454f9dd5eae7a29293711219f33f0d140
|
|
BLAKE2b-256 checksum How to use checksums |
1d25cde2b17cf396df4415ac95288f43641d6441f2ab80e979e0ec1f50d090a2
|
| 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.1-cp312-cp312-manylinux_2_28_x86_64.whl
| Download URL | lucky_tls-0.34.1-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 |
1c372a554ede2eca4e465cbea14ed336bae41f97b67439f007c398afc65895af
|
|
BLAKE2b-256 checksum How to use checksums |
dd3ef51797495f8caee86ff5071c6d45628b95cce6bf5ee8fa96e340262ea909
|
| 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.1-cp311-cp311-win_amd64.whl
| Download URL | lucky_tls-0.34.1-cp311-cp311-win_amd64.whl |
|---|---|
| Size | 4.0 MB |
| Tags | CPython 3.11 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
af05b5d4329b10c79347f473ae140aceea63c34f06e6f331364b45e84ce1189d
|
|
BLAKE2b-256 checksum How to use checksums |
097e82dbd12329b511740e22a0e97bb761c3a2ce393fb092ee2a3d0456c2572d
|
| 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.1-cp311-cp311-manylinux_2_28_x86_64.whl
| Download URL | lucky_tls-0.34.1-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 |
e8cd6464c098d6f3a074c22f859e34aceb9e3b2ddde93b75b13e8d93a60e6628
|
|
BLAKE2b-256 checksum How to use checksums |
98ebf21734dd3671b383e7c2c8949a948803303f0c07c744f4c41605568ee301
|
| 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.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.