A Python script that downloads Hack The Box (HTB) Academy modules and converts them into formatted EPUB books for offline reading.
- Extracts all sections and markdown content from a given HTB Academy module.
- Automatically downloads and embeds images within the EPUB.
- Preserves formatting, tables, and code blocks.
- Generates a clean Table of Contents (ToC) for easy navigation.
Important:
This tool is intended for personal, offline study use only.
You must have an active Hack The Box Academy account with access to the modules.
Do not share or distribute generated EPUB files, as HTB content is copyrighted.
- Python 3.8+
- An active HTB Academy account
-
Clone this repository:
git clone https://github.com/Ewin7/htb2epub.git cd htb2epub -
Install the required dependencies:
pip install -r requirements.txt
-
Set up your environment variables:
Warning
Never share your cookies or .env file. These grant access to your account.
Run the script by providing a module ID. You can find the Module ID in the URL of the HTB Academy module (e.g., https://academy.hackthebox.com/app/module/12345 -> the ID is 12345).
python main.py -i <MODULE_ID>Example:
python main.py -i 12345The script will fetch the module content, download the required images, and generate an EPUB file named <Module_Title>.epub in the current directory.
This project uses the following main libraries:
requests- For API interaction and downloading imagesbeautifulsoup4- For HTML parsing and image tag manipulationmarkdown- To convert HTB's markdown structure to HTMLebooklib- For generating the EPUB file structure
MIT License
