轻量、异步、开箱即用的社交媒体聚合解析库
Project description
✨ 特性
- 🌍 广泛的平台支持 — 覆盖国内外 16+ 主流社交媒体
- 🧹 隐私保护 — 自动清除链接中的跟踪参数, 返回干净的原始链接
- 🎬 多媒体支持 — 视频 / 图文 / 动图 / 实况照片,一网打尽
- 📦 开箱即用 —
async/await原生支持,API 极简 - 🤖 Telegram Bot — 基于本项目的 Bot 已上线 → @ParsehuBot
📦 安装
# pip
pip install parsehub
# uv (推荐)
uv add parsehub
要求 Python ≥ 3.12
🚀 快速开始
from parsehub import ParseHub
result = ParseHub().parse_sync("https://www.xiaoheihe.cn/app/bbs/link/174972336")
print(result)
# ImageParseResult(platform=小黑盒, title=名为希望和绝望的红包, content=[cube_doge][cube_doge][cube_doge], media=[17], raw_url=https://www.xiaoheihe.cn/app/bbs/link/174972336)
下载媒体
from parsehub import ParseHub
result = ParseHub().download_sync("https://www.xiaoheihe.cn/app/bbs/link/174972336")
print(result)
# DownloadResult(media=[ImageFile(path='D:\\downloads\\名为希望和绝望的红包\\0.jpg', width=1773, height=2364), ...], output_dir=D:\downloads\名为希望和绝望的红包)
🌐 支持平台
| 平台 | 视频 | 图文 | 其他 |
|---|---|---|---|
| Twitter / X | ✅ | ✅ | |
| ✅ | ✅ | ||
| YouTube | ✅ | 🎵 音乐 | |
| ✅ | |||
| Threads | ✅ | ✅ | |
| Bilibili | ✅ | 📝 动态 | |
| 抖音 / TikTok | ✅ | ✅ | |
| 微博 | ✅ | ✅ | |
| 小红书 | ✅ | ✅ | |
| 贴吧 | ✅ | ✅ | |
| 微信公众号 | ✅ | ||
| 快手 | ✅ | ||
| 酷安 | ✅ | ✅ | |
| 皮皮虾 | ✅ | ✅ | |
| 最右 | ✅ | ✅ | |
| 小黑盒 | ✅ | ✅ |
🔧 更多平台持续接入中...
🔑 高级用法
下载进度回调
from parsehub import ParseHub
class ProgressTracker:
async def __call__(self, current: int, total: int, unit: str, *args, task_name: str = "", **kwargs):
print(f"[{task_name}] {current}/{total} ({unit})")
result = ParseHub().download_sync(
"https://example.com",
callback=ProgressTracker(),
callback_args=("extra_arg",),
callback_kwargs={"task_name": "demo"},
)
Cookie 登录 & 代理
部分平台的内容需要登录才能访问,通过 Cookie 即可解锁:
from parsehub import ParseHub
ph = ParseHub(cookie="key1=value1; key2=value2", proxy="http://127.0.0.1:7890", )
Cookie 支持多种格式传入:
# 字符串
ParseHub(cookie="key1=value1; key2=value2")
# JSON 字符串
ParseHub(cookie='{"key1": "value1", "key2": "value2"}')
# 字典
ParseHub(cookie={"key1": "value1", "key2": "value2"})
目前支持 Cookie 登录的平台:
Twitter · Instagram · Kuaishou · Bilibili · YouTube
全局配置
from parsehub.config import GlobalConfig
# 自定义默认下载目录
GlobalConfig.default_save_dir = "./my_downloads"
🤝 参考项目
- Evil0ctal/Douyin_TikTok_Download_API
- yt-dlp/yt-dlp
- instaloader/instaloader
- SocialSisterYi/bilibili-API-collect
- Nemo2011/bilibili-api
📜 开源协议
本项目基于 MIT License 开源。
如果这个项目对你有帮助,欢迎点个 ⭐ Star!
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
parsehub-2.0.6.tar.gz
(56.4 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
parsehub-2.0.6-py3-none-any.whl
(73.3 kB
view details)
File details
Details for the file parsehub-2.0.6.tar.gz.
File metadata
- Download URL: parsehub-2.0.6.tar.gz
- Upload date:
- Size: 56.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.28 {"installer":{"name":"uv","version":"0.9.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
587979fa683fbe72568745738a83c333c782170ef8339f9078eae292cfe0c147
|
|
| MD5 |
7ae290df3c23703f3c80e16371245e92
|
|
| BLAKE2b-256 |
514caa4417043e57791795ea170dc405ab69d631a4b7d1a64f4bff24ef75fca4
|
File details
Details for the file parsehub-2.0.6-py3-none-any.whl.
File metadata
- Download URL: parsehub-2.0.6-py3-none-any.whl
- Upload date:
- Size: 73.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.28 {"installer":{"name":"uv","version":"0.9.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a66606762cf74f75a830f5ca91e0a0f67918ec74f90b7a9d77527dd5c6e6d4ad
|
|
| MD5 |
1b0c2f39e18153a22e981cc2556ac297
|
|
| BLAKE2b-256 |
ac18858a1d138998fa473237ddaaf8356d9938ce9e688f71865d031f383ae54d
|