Skip to main content

将 html链接, html文件 或 html文本 转换成 epub文件,并自动添加封面.

Project description

xml2epub

Update

介绍

原项目已经较为成熟 Html2Epub ,此次更改是为了满足自身需求,主要是取消 html string 的清洗:

  • 关于页面清洗:html string 通过 create_chapter_from_string 的参数 strict 控制,False 表示不清洗
  • 关于封面:xml string 中如果包含<title>封面</title>或者<title>cover</title>等,则应该自动生成 epub 文件的封面
  • 关于替换静态资源,做的改进是:
    • 图片的名称由uuid改为md5(url) 作为名称(128位 16个字符),图片文件夹为 img
    • 提取页面中的 css 并保存在 css 文件夹中

使用示例

import xml2epub

epub = xml2epub.Epub('My First Epub')
chapter = xml2epub.create_chapter_from_url('https://en.wikipedia.org/wiki/EPUB')
epub.add_chapter(chapter)
epub.create_epub('OUTPUT_DIRECTORY')

源码推送到pipy

参考:https://zhuanlan.zhihu.com/p/37987613

pip3 install setuptools
pip3 install wheel
# 打包
python3 setup.py sdist bdist_wheel

pip3 install twine
# 上传
twine upload dist/*

参考文献

  1. wcember/pypub: Python library to programatically create epub files.
  2. EPUB - Wikipedia.

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

xml2epub-1.8.tar.gz (15.1 kB view details)

Uploaded Source

Built Distribution

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

xml2epub-1.8-py3-none-any.whl (16.1 kB view details)

Uploaded Python 3

File details

Details for the file xml2epub-1.8.tar.gz.

File metadata

  • Download URL: xml2epub-1.8.tar.gz
  • Upload date:
  • Size: 15.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9

File hashes

Hashes for xml2epub-1.8.tar.gz
Algorithm Hash digest
SHA256 22d2e5e3ab30ab24e839ae2254a1cfb941a97ac56c546d09b0993b5472358973
MD5 b7736ba55e40000975e9d3a1a08e176e
BLAKE2b-256 6b7b668843442733a0da327ba3654d7955528f2e0c491504089cf5ef7e4c7b39

See more details on using hashes here.

File details

Details for the file xml2epub-1.8-py3-none-any.whl.

File metadata

  • Download URL: xml2epub-1.8-py3-none-any.whl
  • Upload date:
  • Size: 16.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9

File hashes

Hashes for xml2epub-1.8-py3-none-any.whl
Algorithm Hash digest
SHA256 4af3cecd2621ae658869c8eb6ccf710369cb651b26239c6d90e8ffeed6e99d80
MD5 2ddd8f4b0895d48c26209f751a73a72e
BLAKE2b-256 b9f02ebd19b639425ed399723d5453738490bb8de2fdb48d047d32183af0fd30

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