1. Products
  2.   eBook
  3.   Python
  4.   Pypub

Open Source Python Library for EPUB File Creation & Reading

Free Python EBook library enables software developers to Read & Create EPUB Files from Websites, HTML Files & Strings.

Pypub is a very powerful open source pure Python Library that enables software developers to create EPUB files from websites, HTML files, Strings inside their Python apps having minimal dependencies. EPUB is useful EBook file format is widely used across the world by publishers & users. The library is available under the MIT license and users are fully allowed to use it inside their projects.

The Pypub library is very simple to handle and enables users to generate EPUB files quickly without worrying about the complexities of the EPUB specification. Once great feature that the library supported is, that it allows users to generate such EPUBs which can be easily converted into Amazon Kindle mobi or azw3 files. There are several important features part of the library such as create EPUBs files from websites, abstracts the EPUB specification, clean up complicated HTML code, create EPUBs files from HTML files, make EPUBs files from strings, fully customizable and many more.

Previous Next

Getting Started with Pypub

Pypub is available at pip, You can easily download it and install it on your machine. Please use the following command for smooth installation.

Install Pypub via pip

$ pip install pypub

You can download the compiled shared library from Github repository.

Create EPUB Documents via Python

The open source Pypub library enables software programmers to create EPUB files with just a couple of lines of code with minimal dependencies. The library has provided numerous methods for creating EPUB files such as EPUB files creation from websites or HTML files, and from strings inside Python applications. To create EPUB from webpage, you just need to provide the complete URL of that page.

Create EPUB Files Online via Python Library

import pypub
my_first_epub = pypub.Epub('My First Epub')
my_first_chapter = pypub.create_chapter_from_url('https://en.wikipedia.org/wiki/EPUB')

Create EPUB from Reddit Stories via Python API

The Pypub library gives software developers the ability to generate EPUB files from Reddit stories inside Python applications. To achieve the task we need to use the python package praw to access Reddit’s api. First you need to the get the URLs of top ten stories from r/TrueReddit section. After getting the list of URL strings, Now we can use Pypub library to download the content and create an EPUB from the stories. You just need to provide the title of the Ebook we are going to create for the top stories.

How to Read Existing EPUB Documents via Python API?

import Pypub
import praw, os

praw_object = praw.Reddit(user_agent='pypub/1.0')
top_submission_list = praw_object.get_subreddit('TrueReddit').get_top(limit=10)
top_submission_url_list = [submission.url for submission in top_submission_list]
epub = pypub.Epub('TrueReddit - Top Stories')
for url in top_submission_url_list:
        c = pypub.create_chapter_from_url(url)
    except ValueError: