markdown-crawler

paulpierre/markdown-crawler

A multithreaded web crawler that converts websites to markdown files for LLM RAG

456
Stars
54
Forks
5
Open issues
5
Watchers
Python MITLast pushed Jun 26, 2026

Overview

markdown-crawler is a Python-based tool that recursively crawls through specified URLs or domains and converts the content of each page into a structured Markdown file. It includes features such as multi-threading, URL validation, configurable depth limits, support for tables and images, browser-like User-Agent headers, and more.

Categories

Tags

Similar tools

Install

pip install markdown-crawler

README

                |                                     |             
 __ `__ \    _` |        __|   __|   _` | \ \  \   /  |   _ \   __| 
 |   |   |  (   |       (     |     (   |  \ \  \ /   |   __/  |    
_|  _|  _| \__._|      \___| _|    \__._|   \_/\_/   _| \___| _|    

---------------------------------
markdown_crawler - by @paulpierre
---------------------------------
A multithreaded 🕸️ web crawler that recursively crawls a website and creates a 🔽 markdown file for each page
https://github.com/paulpierre
https://x.com/paulpierre                                                        



📝 Overview

This is a multithreaded web crawler that crawls a website and creates markdown files for each page. It was primarily created for large language model document parsing to simplify chunking and processing of large documents for RAG use cases. Markdown by nature is human readable and maintains document structure while keeping a small footprint.

✨ Features include

  • 🧵 Threading support for faster crawling
  • ⏯️ Continue scraping where you left off
  • ⏬ Set the max depth of children you wish to crawl
  • 📄 Support for tables, images, etc.
  • ✅ Validates URLs, HTML, filepaths
  • ⚙️ Configure list of valid base paths or base domains
  • 🚫 Exclude specific paths from crawling (--exclude-paths)
  • 🎨 Configurable markdown heading style (--heading-style)
  • 🌐 Browser-like User-Agent to bypass JS checks
  • 🍲 Uses BeautifulSoup to parse HTML
  • 🪵 Verbose logging option
  • 👩‍💻 Ready-to-go CLI interface
  • 🧪 Comprehensive test suite (95% coverage)

📦 What's New in v0.0.9

This release resolves 6 open issues and introduces several community-requested features:

IssueFix
#7UnicodeEncodeError on non-ASCII content — UTF-8 encoding on all file writes
#8Bypass JavaScript checks — browser-like User-Agent header on all requests
#9Exclude paths from crawling — new --exclude-paths / -x CLI flag
#10target_content CSS selector handling — null href links now skipped
#11UnboundLocalError fix in get_target_content
#17Dependencies added to pyproject.toml for uvx support
#20Configurable heading_style for markdownify (ATX, UNDERLINE, etc.)

Also includes a comprehensive test suite — 60 tests, 95% coverage. See the CHANGELOG.md for full details.

🏗️ Use cases

  • RAG (retrieval augmented generation) - my primary usecase, use this to normalize large documents and chunk by header, pargraph or sentence
  • LLM fine-tuning - Create a large corpus of markdown files as a first step and leverage gpt-3.5-turbo or Mistral-7B to extract Q&A pairs
  • Agent knowledge - Leverage this with autogen for expert agents, for example if you wish to reconstruct the knowledge corpus of a videogame or movie, use this to generate the given expert corpus
  • Agent / LLM tools - Use this for online RAG learning so your chatbot continues to learn. Use SERP and scrape + index top N results w/ markdown-crawler
  • many more ..



🚀 Get started

If you wish to simply use it in the CLI, you can run the following command:

Install the package

pip install markdown-crawler

Execute the CLI

markdown-crawler -t 5 -d 3 -b ./markdown https://en.wikipedia.org/wiki/Morty_Smith

To run from the github repo, once you have it checked out:

pip install .
markdown-crawler -t 5 -d 3 -b ./markdown https://en.wikipedia.org/wiki/Morty_Smith

Or use the library in your own code:

from markdown_crawler import md_crawl
url = 'https://en.wikipedia.org/wiki/Morty_Smith'
md_crawl(url, max_depth=3, num_threads=5, base_path='markdown')



⚠️ Requirements

  • Python 3.x
  • BeautifulSoup4
  • requests
  • markdownify



🔍 Usage

The following arguments are supported

usage: markdown-crawler [-h] [--max-depth MAX_DEPTH] [--num-threads NUM_THREADS] [--base-dir