html2epub
简介 / Introduction
原项目为 python2 项目 pypub,此为 python3 项目,并进行了些许修改与优化。
This project is a Python 3 fork of the original pypub (Python 2), with various improvements and optimizations.
将 HTML 链接、HTML 文件或 HTML 文本转换成 EPUB 文件。
Converts HTML links, HTML files, or HTML text into EPUB files.
tips / 提示
关于 EPUB 文件的格式可以参考 EPUB - Wikipedia。
For EPUB format details, refer to EPUB - Wikipedia.
快速使用 / Quick Start
>>> import html2epub
>>> epub = html2epub.Epub('My First Epub')
>>> chapter = html2epub.create_chapter_from_url('https://en.wikipedia.org/wiki/EPUB')
>>> epub.add_chapter(chapter)
>>> epub.create_epub('OUTPUT_DIRECTORY')
安装 / Installation
pip install beautifulsoup4 jinja2 lxml requests
# 或使用 requirements.txt
# or install from requirements.txt
pip install -r requirements.txt
功能特性 / Features
- 从 URL 创建章节 / Create chapters from URLs
- 从 HTML 文件创建章节 / Create chapters from HTML files
- 从 HTML 字符串创建章节 / Create chapters from HTML strings
- 自动清理 HTML 内容 / Automatically clean HTML content
- 支持 CSS 样式 / Support CSS styles
- 支持图片嵌入 / Support image embedding
- 完整的元数据支持 / Full metadata support
API 参考 / API Reference
Epub 类 / Epub Class
epub = html2epub.Epub('Book Title', author='Author Name')
epub.add_chapter(chapter)
epub.set_cover('cover.jpg')
epub.create_epub('output_directory')
创建章节 / Creating Chapters
# 从 URL 创建 / Create from URL
chapter = html2epub.create_chapter_from_url('https://example.com')
# 从文件创建 / Create from file
chapter = html2epub.create_chapter_from_file('path/to/file.html')
# 从字符串创建 / Create from string
chapter = html2epub.create_chapter_from_string('<h1>Hello</h1><p>World</p>')
测试 / Testing
python run_tests.py
Python 版本支持 / Python Version Support
- Python 3.8+
- 已测试并兼容 Python 3.12 和 3.13 / Tested and compatible with Python 3.12 and 3.13
参考文献 / References
许可证 / License
MIT License
Metadata
Release files for html2epub 1.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| html2epub-1.3.tar.gz | 21.9 kB | Without provenance | Details for html2epub-1.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| html2epub-1.3-py3-none-any.whl | Python 3 | none | any | Details for html2epub-1.3-py3-none-any.whl |
Total release size: 40.2 kB
Release files / html2epub-1.3.tar.gz
| Download URL | html2epub-1.3.tar.gz |
|---|---|
| Size | 21.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e0853aed3b2cc33e6cd5f2d762d1b45504bed7f1135160abea6b9e520424f14f
|
|
BLAKE2b-256 checksum How to use checksums |
960394995ebedd6e12e199ebb1ddb29bc919a7f2badd1747fc540ddfe62dbbbb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.2
|
Release files / html2epub-1.3-py3-none-any.whl
| Download URL | html2epub-1.3-py3-none-any.whl |
|---|---|
| Size | 18.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ce93f14633531e2a1388f9ba00a664a0546d3e76ca59a46ce7d3895985772720
|
|
BLAKE2b-256 checksum How to use checksums |
ff0dd26089f19cd3628b304f43b86ea7f5ea0affdfe15ad6799e12651bc1bd91
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.2
|
Security for html2epub 1.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.