Skip to content

ahiser24/MSLearn2eBook

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 

Repository files navigation

MSLearn2eBook

"Turn scattered Microsoft Learn modules into single, offline-ready eBooks."

What It Is & What It Does

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 .epub file with a working Table of Contents.

Prerequisites


Installation

1. Clone the Repository

git clone https://github.com/yourusername/MSLearn2eBook.git
cd MSLearn2eBook

2. Set Up a Virtual Environment (Recommended)

Keep your global Python environment clean by using a virtual environment.

Windows (PowerShell)

# Create virtual environment
python -m venv .venv

# Activate virtual environment
.venv\Scripts\Activate.ps1

macOS / Linux

# Create virtual environment
python3 -m venv .venv

# Activate virtual environment
source .venv/bin/activate

3. Install Dependencies

With the virtual environment activated, install the required packages:

pip install -r requirements.txt

Usage

  1. Activate your virtual environment (if not already active).
  2. Run the script:
    python mslearn2ebook.py
  3. 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/
    

Finding URLs

Browse all available Microsoft Learn content at: Microsoft Learn Catalog. You can copy and paste URLs containing /courses/, /paths/, or /modules/.


Output

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

Using Your 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.

How It Works

  1. Catalog Resolution: Queries the official Microsoft Learn Catalog API (/api/catalog/) to map the URL to a module list.
  2. Unit Discovery: Scrapes each module to find specific child unit URLs (skipping interactive assessments).
  3. Content Extraction: Downloads HTML, strips web-specific UI (nav bars, footers), and fixes relative links.
  4. Image Handling: Images are downloaded to memory and HTML src tags are rewritten for offline support.
  5. EPUB Assembly: Uses ebooklib to compile chapters, apply basic CSS, and generate the Table of Contents.

Requirements

  • requests
  • beautifulsoup4
  • EbookLib

Disclaimer

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.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages