ruyihttp
Requests 风格的 Python HTTP 客户端,使用 Firefox NSS / Necko 原生网络能力。
一条 pip install 即可安装,支持 HTTP/1.1、HTTP/2、HTTP/3、会话、代理和流式请求,无需启动浏览器。
保留你熟悉的 get()、post()、Session 和 Response 用法,通过 Python 接口调用随包附带的原生 DLL。
适合接口调用、数据采集、会话维护,以及需要 NSS TLS 连接的 Python 项目。
pip install -U ruyihttp
import ruyihttp as requests
response = requests.get("https://example.com", timeout=30)
response.raise_for_status()
print(response.text)
快速开始 · 常用功能 · 更多用法 · 赞助商 · 问题反馈
赞助商
| FastAIToken FastAIToken 是面向开发者的 AI API 聚合平台,支持 OpenAI、Claude、Gemini,以及 DeepSeek、GLM、Kimi 等模型。提供多种模型渠道、公开状态页及 7×24 小时真人技术支持。渠道价格与活动以平台页面为准。 注册与了解详情:http://www.fastaitoken.com/register |
快速开始
需要 Windows x64 和 64 位 Python 3.10–3.14。DLL 随 wheel 自动安装,Python 依赖由 pip 解析。
python -m pip install -U ruyihttp
python -c "import ruyihttp; print(ruyihttp.__version__)"
也可以从 GitHub Releases 下载 wheel 后用 pip 安装。
如果系统提示缺少 VCRUNTIME 或 MSVCP,请安装
Microsoft Visual C++ x64 Redistributable。
使用 Session
Session 可复用连接、Cookie 和默认请求头:
import ruyihttp
with ruyihttp.Session() as session:
session.headers.update({"User-Agent": "my-client/1.0"})
response = session.get(
"https://httpbin.org/get",
params={"page": 1, "keyword": "ruyihttp"},
timeout=(5, 30),
)
response.raise_for_status()
print(response.json())
常用功能
| 功能 | 用法 |
|---|---|
| HTTP 请求 | get、post、put、patch、delete、head、options |
| 会话管理 | Session、连接复用、Cookie、默认请求头 |
| 请求数据 | URL 参数、表单、JSON、文件上传、生成器请求体 |
| 响应处理 | text、content、json()、状态码、响应头 |
| 流式下载 | stream=True、iter_content()、iter_lines() |
| 代理 | HTTP、HTTPS、SOCKS4/5、代理认证 |
| 认证与跳转 | Basic / Digest 认证、重定向、响应钩子 |
| 连接控制 | 超时、重试、CA 证书、自定义适配器 |
| 协议 | HTTP/1.1、HTTP/2、通过 HTTPS Alt-Svc 选择 HTTP/3 |
| TLS 信息 | response.tls 查看协商协议、版本及会话信息 |
更多用法
发送 JSON
import ruyihttp
response = ruyihttp.post(
"https://httpbin.org/post",
json={"name": "ruyihttp", "enabled": True},
timeout=30,
)
response.raise_for_status()
print(response.json())
使用代理
import ruyihttp
response = ruyihttp.get(
"https://example.com",
proxies={"https": "http://127.0.0.1:8080"},
timeout=30,
)
SOCKS 代理先安装可选依赖,再使用 socks5h://127.0.0.1:1080 等代理地址:
pip install "ruyihttp[socks]"
流式下载
import ruyihttp
with ruyihttp.get("https://example.com", stream=True, timeout=30) as response:
response.raise_for_status()
with open("page.html", "wb") as output:
for chunk in response.iter_content(chunk_size=65536):
output.write(chunk)
配置重试
from ruyihttp import Session
from ruyihttp.adapters import HTTPAdapter
from urllib3.util import Retry
with Session() as session:
session.mount("https://", HTTPAdapter(max_retries=Retry(total=3)))
response = session.get("https://example.com", timeout=(5, 30))
response.raise_for_status()
查看 TLS 信息
import ruyihttp
response = ruyihttp.get("https://example.com", timeout=30)
print(response.tls)
反馈与交流
欢迎通过 Issues 反馈问题或提出功能建议。 反馈时请附上 Python 版本、ruyihttp 版本、最小复现代码和错误信息,分享前移除 Cookie、Token 等私密数据。
相关项目:ruyiPage 提供 Firefox 浏览器自动化能力,适合需要页面操作的场景。
许可证
Python 接口代码采用 MPL-2.0。 原生 DLL、第三方组件许可及对应源码提供状态见 THIRD_PARTY_NOTICES.md。
Metadata
Release files for ruyihttp 0.8.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distributions (wheels)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| ruyihttp-0.8.1-py3-none-win_amd64.whl | Python 3 | none | Windows x86-64 | Details |
| ruyihttp-0.8.1-py3-none-manylinux_2_31_x86_64.whl | Python 3 | none | Linux glibc 2.31+ x86-64 | Details |
Total release size: 7.8 MB
Release files / ruyihttp-0.8.1-py3-none-win_amd64.whl
| Download URL | ruyihttp-0.8.1-py3-none-win_amd64.whl |
|---|---|
| Size | 4.0 MB |
| Tags | Python 3 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
b363b0de3a9228995acde7112848dcc450dfd8b9a64c7ae1723b3af9dd1ff10e
|
|
BLAKE2b-256 checksum How to use checksums |
9d2d5fcf3414224f043177750519bb16bf9dc51596c88618f84c25077eb6ee80
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 21, 2026.
Transparency logRelease files / ruyihttp-0.8.1-py3-none-manylinux_2_31_x86_64.whl
| Download URL | ruyihttp-0.8.1-py3-none-manylinux_2_31_x86_64.whl |
|---|---|
| Size | 3.9 MB |
| Tags | Linux glibc 2.31+ x86-64 Python 3 |
|
SHA-256 checksum How to use checksums |
4ca50f90a1fc29d7b4b2516dd94340747551a220ff109733f79bd0e23a0b553c
|
|
BLAKE2b-256 checksum How to use checksums |
177c7246a1f3f06a85e955e0d5931a0c9dde3485e32aa661a5e326d8bec6c9a9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 21, 2026.
Transparency logSecurity for ruyihttp 0.8.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.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for ruyihttp-0.8.1-py3-none-win_amd64.whl
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 21, 2026.
Transparency logA 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.