导出微信聊天记录为 HTML / Markdown — Export WeChat conversations to HTML or Markdown
Project description
DaoChu(导出)
DaoChu(导出)是一个 Python 命令行工具,能将微信聊天记录导出为精美的 HTML 页面或 Markdown 文件。
支持解密后的微信 SQLite 数据库、CSV 导出、JSON 导出三种数据源。
✨ 特性
- 🎨 精美 HTML 输出 — 仿微信气泡样式,带日期分组、响应式设计
- 📝 Markdown 输出 — 纯文本,适合归档或导入笔记工具
- 🔍 自动联系人发现 —
list-contacts命令快速查看所有联系人 - 🧠 智能解析 — 自动识别文件类型(.db / .csv / .json)
- 🖼️ 媒体标注 — 图片、语音、视频、链接等自动标注为可读文本
📦 安装
pip install daochu
要求 Python ≥ 3.10。
🚀 快速开始
1. 列出联系人
daochu list-contacts /path/to/decrypted/MSG.db
2. 导出聊天记录
# 导出为 HTML(默认)
daochu export MSG.db "wxid_abc123"
# 导出为 Markdown
daochu export MSG.db "wxid_abc123" -f md
# 指定输出路径
daochu export MSG.db "wxid_abc123" -o ~/Desktop/chat.html
# 自定义自己的显示名
daochu export MSG.db "wxid_abc123" --me "小明"
📂 数据源说明
| 类型 | 说明 |
|---|---|
| SQLite (.db) | 解密后的微信 Msg 数据库,最常见的方式 |
| CSV (.csv) | 从第三方工具导出的 CSV,需含 timestamp/sender/content 列 |
| JSON (.json) | 消息对象数组,格式 [{timestamp, sender, content}] |
如何获取解密数据库? 微信数据库默认加密存储在
Documents/WeChat Files/<wxid>/Msg/下。可使用开源工具解密后配合 DaoChu 使用。
🖥️ 命令行参考
Usage: daochu [OPTIONS] COMMAND [ARGS]...
Commands:
export 导出与某个联系人的全部聊天记录
list-contacts 列出数据库中的所有联系人
export 选项:
-o, --output PATH 输出目录或文件路径
-f, --format [html|md] 输出格式
--me TEXT 自己的显示名称
--source-type [auto|db|csv|json]
--table TEXT 数据库表名
--encoding TEXT 文件编码
🐍 Python API
from daochu.parser import parse_db
from daochu.exporter import export
conv = parse_db("MSG0.db", "wxid_abc123", my_name="我")
export(conv, "output.html", fmt="html")
🖼️ 效果预览
HTML 输出效果:
- 顶部:联系人名称、日期范围、消息总数
- 每一条消息:微信风格气泡,自己的消息靠右显示为绿色
- 日期分组:按天自动插入日期分隔线
- 移动端适配:响应式设计,手机上也能流畅阅读
📄 License
MIT © DaoChu Contributors
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
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
File details
Details for the file daochu-0.1.0.tar.gz.
File metadata
- Download URL: daochu-0.1.0.tar.gz
- Upload date:
- Size: 13.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
78e226f00fbb5abf640a766f9eefc9d2a8db3c43b0dd4f22fb3bafe6e6948dfa
|
|
| MD5 |
dfdb0b36b4ffa8c540e94bdca71e59f6
|
|
| BLAKE2b-256 |
a5cf4bbf84d7d16f7ae554b49560155c75f9ce5820f44012cd22e959a96ba104
|
File details
Details for the file daochu-0.1.0-py3-none-any.whl.
File metadata
- Download URL: daochu-0.1.0-py3-none-any.whl
- Upload date:
- Size: 13.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
419070b4528adf2ae6aa75e0dc702f893b3e424d9aa3f023574c3c37bd66e2da
|
|
| MD5 |
8183b04ed9e16ff0332e6371017d7dae
|
|
| BLAKE2b-256 |
0052052a5d274088a4018b9eba9e8495ec0fa7227bed8ab3f9d5432bf4bcc353
|