"Turn scattered Microsoft Learn modules into single, offline-ready eBooks."
MSLearn2eBook is a local Python script that extracts content from Microsoft Learn and converts it into a standard eBook format. Instead of dealing with endless browser tabs, this tool takes an entire Course, Learning Path, or Module and stitches it into a single, perfectly formatted EPUB.
- Universal Support: Paste a URL for a full Course (
/courses/), a Learning Path (/paths/), or a single Module (/modules/). - Official API Integration: Uses the Microsoft Learn Catalog API to accurately discover course structures.
- Smart Cleaning: Strips out navigation bars, UI buttons, and "Knowledge Check" quizzes.
- Native Images: Downloads all course images locally and embeds them directly.
- True EPUB Output: Generates a standard
.epubfile with a working Table of Contents.
- Python 3.8 or higher - Download Python
git clone https://github.com/yourusername/MSLearn2eBook.git
cd MSLearn2eBookKeep your global Python environment clean by using a virtual environment.
# Create virtual environment
python -m venv .venv
# Activate virtual environment
.venv\Scripts\Activate.ps1# Create virtual environment
python3 -m venv .venv
# Activate virtual environment
source .venv/bin/activateWith the virtual environment activated, install the required packages:
pip install -r requirements.txt- Activate your virtual environment (if not already active).
- Run the script:
python mslearn2ebook.py
- Enter a Microsoft Learn URL when prompted:
======================================== 📚 MS Learn to EPUB Converter ======================================== Enter a Microsoft Learn Course, Path, or Module URL: > https://learn.microsoft.com/en-us/training/paths/build-ai-solutions-with-azure-openai/
Browse all available Microsoft Learn content at: Microsoft Learn Catalog. You can copy and paste URLs containing /courses/, /paths/, or /modules/.
The script will create an ebooks/ directory in the same folder as the script. Your generated .epub files will be saved there, automatically named after the course.
MSLearn2eBook/
├── mslearn2ebook.py
├── requirements.txt
└── ebooks/
└── MSLearn_Course_Name.epub
Once your .epub file is generated, you can use it to supercharge your studying:
- Google NotebookLM: Upload your eBook to NotebookLM to generate AI study guides, flashcards, or Audio Overviews.
- Amazon Kindle: Send the file via Amazon Send to Kindle.
- Apple Devices: Open natively in Apple Books.
- Android: Open using Google Play Books or any standard e-reader app.
- Catalog Resolution: Queries the official Microsoft Learn Catalog API (
/api/catalog/) to map the URL to a module list. - Unit Discovery: Scrapes each module to find specific child unit URLs (skipping interactive assessments).
- Content Extraction: Downloads HTML, strips web-specific UI (nav bars, footers), and fixes relative links.
- Image Handling: Images are downloaded to memory and HTML
srctags are rewritten for offline support. - EPUB Assembly: Uses
ebooklibto compile chapters, apply basic CSS, and generate the Table of Contents.
requestsbeautifulsoup4EbookLib
This project is a personal, open-source tool designed for offline study. All text, images, and course materials are the copyrighted property of Microsoft. Please use this tool responsibly and strictly for personal, non-commercial educational purposes.