0x676e67/wreq-python

GitHub: 0x676e67/wreq-python

一个基于 BoringSSL 的高性能 Python HTTP 客户端,通过可定制的 TLS 和 HTTP/2 指纹实现高保真浏览器行为模拟,帮助对抗基于协议指纹的流量检测与识别。

Stars: 1322 | Forks: 103

# wreq [![CI](https://static.pigsec.cn/wp-content/uploads/repos/2026/04/fbe40bf70b104346.svg)](https://github.com/0x676e67/wreq-python/actions/workflows/ci.yml) ![PyPI - License](https://img.shields.io/pypi/l/wreq) ![Python Version from PEP 621 TOML](https://img.shields.io/python/required-version-toml?tomlFilePath=https%3A%2F%2Fraw.githubusercontent.com%2F0x676e67%2Fwreq-python%2Fmain%2Fpyproject.toml&logo=python) [![PyPI](https://img.shields.io/pypi/v/wreq?logo=python)](https://pypi.org/project/wreq/) [![Discord chat](https://img.shields.io/discord/1486741856397164788.svg?logo=discord)][discord-url] 一个符合人体工程学且模块化的 Python HTTP 客户端,用于高保真协议匹配,具备可自定义的 TLS、JA3/JA4 和 HTTP/2 签名功能,由 [wreq](https://github.com/0x676e67/wreq) 提供支持。 ## 功能 - 异步与阻塞 `Client` - 纯文本请求体、JSON、URL 编码、Multipart - HTTP Trailer - Cookie 存储 - 重定向策略 - 原始请求头 - 轮换代理 - 连接池 - 流式传输 - 零拷贝传输 - WebSocket 升级 - 基于 BoringSSL 的 HTTPS - 自由线程安全 - 自动解压 - 证书存储 (CAs & mTLS) ## 示例 以下示例使用 `asyncio` 运行时环境,并通过 pip 安装了 `wreq`: ``` pip install wreq ``` 然后是代码: ``` import asyncio from wreq import Client, Emulation async def main(): # Build a client client = Client(emulation=Emulation.Firefox149) # Use the API you're already familiar with resp = await client.get("https://tls.peet.ws/api/all") print(await resp.text()) if __name__ == "__main__": asyncio.run(main()) ``` 其他学习资源包括: - [示例](https://github.com/0x676e67/wreq-python/tree/main/examples) - [DeepWiki](https://deepwiki.com/0x676e67/wreq-python) - [文档](https://python.wreq.org) ## 行为 1. **基于 TLS 的 HTTP/2** 由于 TLS 加密的复杂性以及 HTTP/2 的广泛普及,**JA3**、**JA4** 和 **Akamai** 等浏览器指纹无法使用简单的指纹字符串进行可靠模拟。`wreq` 并没有去解析和模拟这些基于字符串的指纹,而是提供了对 TLS 和 HTTP/2 扩展及设置的细粒度控制,从而实现精确的浏览器行为模拟。 2. **设备模拟** **TLS** 和 **HTTP/2** 指纹在各种浏览器模型中通常是相同的,因为这些底层协议的演进速度慢于浏览器的发布周期。**wreq** 中维护了 **100 多个浏览器设备模拟[配置文件](https://python.wreq.org/en/latest/getting-started/introduction/#behavior)**。 ## 构建 1. 平台 - Linux(**glibc**/**musl**):`x86_64`、`aarch64`、`armv7`、`i686` - macOS:`x86_64`、`aarch64` - Windows:`x86_64`、`i686`、`aarch64` - Android:`aarch64`、`x86_64` 2. 开发 参考 [boringssl](https://github.com/google/boringssl/blob/main/BUILDING.md) 安装 BoringSSL 构建环境。 ``` # 在 ubuntu 或 debian 上 sudo apt install -y build-essential cmake perl pkg-config libclang-dev musl-tools git curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh pip install uv maturin uv venv source .venv/bin/activate # 开发 maturin develop --uv # 构建 wheels maturin build --release ``` ## 基准测试 根据我们由 [pyperf](https://github.com/psf/pyperf) 驱动的[基准测试](https://github.com/0x676e67/wreq-python/tree/main/bench),其性能优于 `requests`、`httpx`、`aiohttp` 和 `curl_cffi`,但结果仅供参考,因为它们会因环境而异。 ## 服务 通过寻求[商业支持](mailto:gngppz@gmail.com),帮助维持这个开源项目的持续开发。您将获得私人指导、专家评审或直接与维护者沟通的机会,并获得为您需求量身定制的个性化技术协助。 ## 许可证 根据 Apache License, Version 2.0 ([LICENSE](./LICENSE) 或 http://www.apache.org/licenses/LICENSE-2.0) 授权。 仅靠 TLS 指纹识别不足以应对现代机器人防护。**[Hyper Solutions](https://hypersolutions.co?utm_source=github&utm_medium=readme&utm_campaign=rnet)** 提供了缺失的环节 - 生成有效防机器人 token 的 API 端点,适用于: **Akamai** • **DataDome** • **Kasada** • **Incapsula** 无需浏览器自动化。只需简单的 API 调用,即可返回这些系统所需的确切 cookie 和标头。 **[控制面板](https://hypersolutions.co?utm_source=github&utm_medium=readme&utm_campaign=rnet)** | **[文档](https://docs.justhyped.dev)** | **[Discord](https://discord.gg/akamai)**
标签:asyncio, ATT&CK 框架, BoringSSL, Google搜索, HTTP/2, HTTPS, JA3, JA4, mTLS, Python, Radare2, SEO优化, TLS指纹, WebSocket, Web爬虫, 代理轮换, 依赖分析, 协议指纹, 反检测, 反爬虫, 可视化界面, 多架构支持, 异步IO, 指纹伪装, 指纹伪造, 无后门, 流式传输, 网络安全, 网络请求库, 计算机取证, 连接池, 逆向工具, 通知系统, 隐私保护, 零拷贝, 高并发