名称: weread
描述: |
微信读书命令行工具,用于获取笔记与高亮。
适用场景:(1) 用户询问微信读书笔记或高亮,
(2) 获取今日或近期阅读笔记,(3) 导出书籍高亮,
(4) 管理阅读书架,(5) 任何涉及微信读书笔记的任务。
用于从微信读书获取笔记与高亮的命令行工具。
# 通过微信二维码登录
weread login
# 列出有笔记的书籍
weread list
# 获取某本书的高亮
weread get <bookId>
weread login # 打开浏览器进行二维码登录
weread logout # 清除已保存的 Cookie
weread whoami # 检查登录状态
# 列出所有有笔记的书籍
weread list [--json]
# 获取书籍高亮与书评
weread get <bookId> [options]
--json, -j 输出 JSON 格式
--highlights, -H 仅显示高亮
--reviews, -R 仅显示书评
--since, -s 按日期筛选 (today, yesterday, YYYY-MM-DD)
# 列出书架上的书籍(按最近阅读时间排序)
weread shelf [-n <limit>] [--json]
获取特定日期之后创建的笔记:
# 某本书的今日高亮
weread get CB_3x2HoH --since today
# 昨日笔记
weread get CB_3x2HoH --since yesterday
# 特定日期之后的笔记
weread get CB_3x2HoH --since 2024-01-15
将书籍高亮导出为 Markdown 文件:
# 仅导出高亮
weread get CB_3x2HoH -H > notes.md
# 导出全部内容(含书评)
weread get CB_3x2HoH > notes.md
文本输出已按章节标题 (## Chapter) 和引用标记 (>) 格式化。
使用 JSON 输出进行批量处理:
# 获取所有高亮文本
weread get CB_3x2HoH --json | jq -r '.highlights[].markText'
# 统计每章高亮数量
weread get CB_3x2HoH --json | jq '.chapters | length'
# 提取书籍信息
weread get CB_3x2HoH --json | jq '.book | {title, author}'
# 列出所有有笔记的书籍 ID
weread list --json | jq -r '.[].bookId'
# 获取所有书籍的高亮总数
weread list --json | jq '[.[].bookmarkCount] | add'
列出并管理你的书架:
# 最近阅读的 10 本书
weread shelf -n 10
# 以 JSON 格式列出所有书籍
weread shelf --json
# 从书架获取书籍 ID
weread shelf --json | jq -r '.[].bookId'
工作流:获取书架 -> 从每本书获取今日笔记:
# 步骤 1:从书架获取近期书籍
weread shelf -n 5 --json | jq -r '.[].bookId'
# 步骤 2:为每本书获取今日笔记
for id in $(weread shelf -n 5 --json | jq -r '.[].bookId'); do
echo "=== 书籍: $id ==="
weread get "$id" --since today -H
done
# 单行命令:从最近 3 本书获取笔记
for id in $(weread shelf -n 3 --json | jq -r '.[].bookId'); do weread get "$id" --since today; done
包含书名:
# 获取带书名的近期笔记
weread shelf -n 5 --json | jq -c '.[] | {id: .bookId, title: .title}' | while read book; do
id=$(echo "$book" | jq -r '.id')
title=$(echo "$book" | jq -r '.title')
echo "=== $title ==="
weread get "$id" --since today -H
done
优先级:环境变量 > 本地缓存 > CookieCloud
二维码登录(推荐):
bash
weread login
环境变量:
bash
export WEREAD_COOKIE="wr_vid=xxx;wr_skey=xxx"
weread list
CookieCloud(用于同步 Cookie):
bash
export COOKIECLOUD_SERVER="https://your-server.com"
export COOKIECLOUD_UUID="your-uuid"
export COOKIECLOUD_PASSWORD="your-password"
weread list
问:如何找到书籍 ID?
weread list --json | jq '.[] | {title: .book.title, id: .bookId}'
问:Cookie 过期了?
weread logout && weread login
问:Cookie 存储在哪里?
~/.config/weread/cookies.json