Skip to main content

use ebooklib to parse a tree-like structure from ebooks from the TOC

Project description

ebook-tree-parser

use ebooklib to parse a tree-like structure from ebooks from the TOC

Usage

from ebooklib import epub
from ebook_tree_parser.toctree import TocTree

file = "../data/frankenstein.epub"
book = epub.read_epub(file, options={'ignore_ncx': False})

estimator = lambda string: len(string)*4
tree = TocTree(book, token_estimator=estimator)

print(tree)

for node in tree3:
    print("----")
    print(f"{node.title}|{node.content_token_count}\n{node.content[:50]}")
    print("----")

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

ebook_tree_parser-0.1.0.tar.gz (5.2 kB view hashes)

Uploaded Source

Built Distribution

ebook_tree_parser-0.1.0-py3-none-any.whl (5.7 kB view hashes)

Uploaded Python 3

Supported by

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