Skip to main content

微信聊天记录截图导出 — Export WeChat conversations via screenshots + OCR

Project description

DaoChu(导出)

PyPI version Python License: GPL v3

DaoChu(导出)是一个 Python 命令行工具,能将微信聊天记录导出为精美的 HTML 页面或 Markdown 文件。

通过截屏 + OCR 零侵入导出微信聊天记录。不碰任何微信数据文件。


✨ 特性

  • 📸 截图 OCR 导出 — 零数据侵入,自动截屏+中文 OCR
  • 🎨 精美 HTML 输出 — 仿微信气泡样式,带日期分组、响应式设计
  • 📝 Markdown 输出 — 纯文本,适合归档或导入笔记工具
  • 🖼️ 自动去重 — 相邻截图重叠内容智能合并

📦 安装

pip install daochu

要求 Python ≥ 3.10。


🚀 快速开始

1. 准备

  • macOS 系统(依赖 screencapture / osascript 自带)
  • 安装 Tesseract OCR:brew install tesseract
  • 中文语言包(脚本首次运行会自动下载)

2. 导出聊天记录

# 打开微信,进入目标聊天窗口,滚动到对话最顶部
# 然后运行:
python tools/screenshot_export.py -o 聊天记录.html

# 英文系统微信
python tools/screenshot_export.py -w "WeChat" -o chat.md -f md

# 限制最大截图数
python tools/screenshot_export.py -n 30

原理:AppleScript 控制微信窗口 → 逐页截屏 → Tesseract OCR 识别中文 → 智能去重 → 导出 HTML/Markdown。

3. 输出效果

  • 仿微信气泡样式 HTML(自己的消息靠右绿色,对方靠左白色)
  • 纯文本 Markdown(适合归档、笔记软件导入)
  • 自动按发送者分组,连续消息合并在同一气泡

🖥️ 命令行参考

Usage: python tools/screenshot_export.py [OPTIONS]

选项:
  -w, --window TEXT          微信窗口标题 (默认: 微信)
  -o, --output PATH          输出文件路径
  -f, --format [html|md]     输出格式 (默认: html)
  -n, --max-screenshots INT  最大截图数 (默认: 50)
  --chat-area-top-offset INT 聊天区距窗口顶部偏移 (默认: 80px)
  --dry-run                  仅截图不 OCR(调试用)

🖼️ 效果预览

HTML 输出效果:

  • 顶部:联系人名称、日期范围、消息总数
  • 每一条消息:微信风格气泡,自己的消息靠右显示为绿色
  • 日期分组:按天自动插入日期分隔线
  • 移动端适配:响应式设计,手机上也能流畅阅读

📄 License

GPL-3.0-or-later © DaoChu Contributors

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

daochu-0.2.0.tar.gz (21.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

daochu-0.2.0-py3-none-any.whl (22.0 kB view details)

Uploaded Python 3

File details

Details for the file daochu-0.2.0.tar.gz.

File metadata

  • Download URL: daochu-0.2.0.tar.gz
  • Upload date:
  • Size: 21.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for daochu-0.2.0.tar.gz
Algorithm Hash digest
SHA256 7362aff7ded7691c93fd8c90161b9ff0670ab6ad3551d1984f91f7806473f08a
MD5 914a76fd850d33782dca1b6d7b86dba4
BLAKE2b-256 d0212f862abfde748c56644ccc3076fcffbe1690df99cb855b623038e339f1d6

See more details on using hashes here.

File details

Details for the file daochu-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: daochu-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 22.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for daochu-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1baaff18f2efe2a2b27f3358c1356aeb738acb246a9c936b6ebfced90d015cd9
MD5 dbc4c58a9728b7084dcf3262a69e9da9
BLAKE2b-256 d27dce83423a023ed139bdca3d816822acf20a50772189021d9f12ce17e5d790

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page