A streamlined Python tool that crawls websites and converts them into organized Markdown files. Powered by crawl4ai for efficient web scraping and Ollama's AI for intelligent content summarization. Turn any website into a clean, local Markdown documentation with just one command.
Features: 🚀
- Smart website crawling with same-domain focus
- AI-powered content summarization
- Page-by-page Markdown conversion
- Configurable AI models through Ollama
- Automatic directory organization
- Crawls entire websites while staying within the same domain
- Creates separate Markdown files for each page
- Intelligently names files based on URL structure
- Summarizes content using configurable Ollama AI models
- Handles relative and absolute URLs
- Avoids duplicate page processing
- Maintains original page structure in Markdown format
- Python 3.x
- Ollama installed and running locally
- Virtual environment (recommended)
- Clone the repository:
git clone https://github.com/Saurabh7636/crawl2md
cd crawl2md- Create and activate a virtual environment (recommended):
python -m venv .venv
source .venv/bin/activate # On Windows, use: .venv\Scripts\activate- Install the required packages:
pip install -r requirements.txt- Set up environment configuration:
cp .env.example .envEdit the .env file to configure your settings:
OLLAMA_MODEL=mistral # Change to any model available in your Ollama installation
OLLAMA_HOST=http://localhost:11434 # Change if Ollama is running on a different host- Make sure Ollama is running with your chosen model:
ollama run $OLLAMA_MODEL # Replace with your chosen model from .env- Run the scraper with a website URL:
python crawl2md.py https://example.comThe script will:
- Create a directory named after the website's domain
- Crawl all pages within the same domain
- Generate Markdown files for each page
- Show progress and completion status
For each page, a Markdown file is created with:
- Page title as heading
- Original URL for reference
- AI-summarized content in a structured format
Example directory structure:
example_com/
├── home.md
├── about.md
├── contact.md
└── blog.md
OLLAMA_MODEL: The Ollama model to use for summarization (default: mistral)OLLAMA_HOST: The Ollama API host address (default: http://localhost:11434)
CacheMode: Controls caching behaviorprocess_iframes: Whether to process iframe contentremove_overlay_elements: Removes overlay elements for better content extractionexclude_external_links: Prevents crawling external domains
- crawl4ai: Web crawling functionality
- BeautifulSoup4: HTML parsing
- requests: HTTP requests
- Ollama: AI-powered content summarization
- python-dotenv: Environment variable management
- Only processes pages within the same domain
- Requires Ollama running locally
- Text summarization limited to 4000 characters per page
- May not handle JavaScript-rendered content
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.