Skip to main content

A multithreaded 🕸️ web crawler that recursively crawls a website and creates a 🔽 markdown file for each page

Project description

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

---------------------------------------------
simple_markdown_crawler - by @yukiteru_amano
---------------------------------------------
A multithreaded 🕸️ web crawler that recursively crawls a website and creates a 🔽 markdown file for each page.
This project is a fork from markdown_crawler from Paul Pierre (abandoned for 2 years).
https://github.com/yukiteruamano
https://x.com/yukiteru_amano



📝 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, base domains and exclude paths
  • 🍲 Uses BeautifulSoup to parse HTML
  • 🪵 Verbose logging option
  • 👩‍💻 Ready-to-go CLI interface

🏗️ 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-4o or mistral-small 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
  • Knowledge database for OpenWebUI and others toosl for LLM Chats.
  • And 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 simple-markdown-crawler

Execute the CLI

simple-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 .
simple-markdown-crawler -t 5 -d 3 -b ./markdown https://en.wikipedia.org/wiki/Morty_Smith

Or use the library in your own code:

from simple_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.10+
  • BeautifulSoup4
  • requests
  • markdownify



🔍 Usage

The following arguments are supported

usage: simple-markdown-crawler [-h] [--max-depth MAX_DEPTH] [--num-threads NUM_THREADS] [--base-path BASE_PATH] [--debug DEBUG]
                  [--target-content TARGET_CONTENT] [--target-links TARGET_LINKS] [--valid-paths VALID_PATHS] [--exclude-paths EXCLUDE_PATHS]
                  [--domain-match DOMAIN_MATCH] [--base-path-match BASE_PATH_MATCH]
                  [--links ]
                  base-url



📝 Example

Take a look at example.py for an example implementation of the library. In this configuration we set:

  • max_depth to 3. We will crawl the base URL and 3 levels of children
  • num_threads to 5. We will use 5 parallel(ish) threads to crawl the website
  • base_dir to markdown. We will save the markdown files in the markdown directory
  • valid_paths an array of valid relative URL paths. We will only crawl pages that are in this list and base path
  • exclude_paths an array of exclude relative URL paths.
  • target_content to div#content. We will only crawl pages that have this HTML element using CSS target selectors. You can provide multiple and it will concatenate the results
  • is_domain_match to False. We will only crawl pages that are in the same domain as the base URL
  • is_base_path_match to False. We will include all URLs in the same domain, even if they don't begin with the base url
  • is_debug to True. We will print out verbose logging

And when we run it we can view the progress

cli

We can see the progress of our files in the markdown directory locally

md

And we can see the contents of the HTML converted to markdown

md



❤️ Thanks

If you have any issues, please feel free to open an issue or submit a PR. You can reach me via DM on Twitter/X.



⚖️ License

MIT License Copyright (c) 2023 Paul Pierre Copyright (c) 2025 Jose Maldonado Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.



markdownify credits

simple_markdown_crawler makes use of markdownify by Matthew Tretter. The original source code can be found here. It is licensed under the MIT license.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

simple_markdown_crawler-0.2.0.tar.gz (11.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

simple_markdown_crawler-0.2.0-py3-none-any.whl (10.7 kB view details)

Uploaded Python 3

File details

Details for the file simple_markdown_crawler-0.2.0.tar.gz.

File metadata

File hashes

Hashes for simple_markdown_crawler-0.2.0.tar.gz
Algorithm Hash digest
SHA256 0a53aec0a86cdffe99df11164b4074c2107a68ab57697c4fd36a44f2da56a3cb
MD5 6967bc20762d0e786cb3722d7aec118f
BLAKE2b-256 ee68a576bcc989dc4d0d6f863b85b0dcdc6363aba1286c9d2f345dc20da9b5b3

See more details on using hashes here.

File details

Details for the file simple_markdown_crawler-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for simple_markdown_crawler-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1f5d5a986f146792630d19c86c1f5fede388f94697e725a9efe5bbb38ebd93b3
MD5 c88ca5c7511b56f5f96609e55dfc6f2f
BLAKE2b-256 dfaadc2c8c1773eb787d19f81cbca8db2cc5b19afc71cd94529a3fbd9e889fa1

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page