提取kindle笔记

首先在Kindle上通过邮件把笔记分享到自己的邮箱,然后把html下载到本地,执行下面的脚本:

#!/usr/bin/env python
import os
import sys

from lxml import html


def extract_notes(s):
    etree = html.fromstring(s)

    for i in etree.find_class("noteText"):
        yield i.text


if __name__ == "__main__":
    notes = []

    with open(sys.argv[1]) as f:
        s = f.read()
        for i in extract_notes(s):
            notes.append(i)

    print("".join(notes))

执行之后,就会输出提取之后的文档。

$ python kindle.py 读书笔记.html

2019.11.12注:

网页版已经移除,请使用脚本。先安装Python3,然后pip安装lxml,之后即可执行此脚本。


更多文章
  • 写一个简单的ORM
  • 从源码看Python的descriptor
  • Python字符串格式化
  • Gunicorn 简明教程
  • Raft 论文阅读笔记
  • 什么是 Golang Comparable Types
  • GFS 论文阅读
  • MapReduce 论文阅读
  • 一起来做贼:Goroutine原理和Work stealing
  • Go语言的defer, panic和recover
  • 再读 Python Language Reference
  • 再读vim help:vim小技巧
  • 设计模式(2)- 深入浅出设计模式 阅读笔记
  • 设计模式(1)- 深入浅出设计模式 阅读笔记
  • Cython! Python和C两个世界的交叉点