{"id":13584818,"url":"https://github.com/paulpierre/markdown-crawler","last_synced_at":"2025-04-13T05:06:15.108Z","repository":{"id":203369622,"uuid":"709317996","full_name":"paulpierre/markdown-crawler","owner":"paulpierre","description":"A multithreaded 🕸️ web crawler that recursively crawls a website and creates a 🔽 markdown file for each page, designed for LLM RAG","archived":false,"fork":false,"pushed_at":"2024-08-13T06:01:13.000Z","size":1191,"stargazers_count":373,"open_issues_count":14,"forks_count":43,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-04-04T05:06:07.177Z","etag":null,"topics":["html-to-markdown","html-to-markdown-converter","html2md","llm","llmops","markdown","markdown-crawler","markdown-parser","markdown-scraper","md-crawler","rag","web-scraper"],"latest_commit_sha":null,"homepage":"https://pypi.org/project/markdown-crawler/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/paulpierre.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-10-24T13:30:06.000Z","updated_at":"2025-04-04T03:03:31.000Z","dependencies_parsed_at":null,"dependency_job_id":"61a277d4-a47d-4ff8-824e-de35a076bb06","html_url":"https://github.com/paulpierre/markdown-crawler","commit_stats":null,"previous_names":["paulpierre/md_crawler"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paulpierre%2Fmarkdown-crawler","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paulpierre%2Fmarkdown-crawler/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paulpierre%2Fmarkdown-crawler/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paulpierre%2Fmarkdown-crawler/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/paulpierre","download_url":"https://codeload.github.com/paulpierre/markdown-crawler/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248665748,"owners_count":21142123,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["html-to-markdown","html-to-markdown-converter","html2md","llm","llmops","markdown","markdown-crawler","markdown-parser","markdown-scraper","md-crawler","rag","web-scraper"],"created_at":"2024-08-01T15:04:32.374Z","updated_at":"2025-04-13T05:06:15.089Z","avatar_url":"https://github.com/paulpierre.png","language":"Python","funding_links":[],"categories":["*Ops for AI","Python"],"sub_categories":["Model Serving \u0026 Inference"],"readme":"```\n                |                                     |             \n __ `__ \\    _` |        __|   __|   _` | \\ \\  \\   /  |   _ \\   __| \n |   |   |  (   |       (     |     (   |  \\ \\  \\ /   |   __/  |    \n_|  _|  _| \\__._|      \\___| _|    \\__._|   \\_/\\_/   _| \\___| _|    \n\n---------------------------------\nmarkdown_crawler - by @paulpierre\n---------------------------------\nA multithreaded 🕸️ web crawler that recursively crawls a website and creates a 🔽 markdown file for each page\nhttps://github.com/paulpierre\nhttps://x.com/paulpierre                                                        \n```\n\u003cbr\u003e\u003cbr\u003e\n\n# 📝 Overview\nThis is a multithreaded web crawler that crawls a website and creates markdown files for each page.\nIt was primarily created for large language model document parsing to simplify chunking and processing of large documents for RAG use cases.\nMarkdown by nature is human readable and maintains document structure while keeping a small footprint.\n\u003cbr\u003e\n\n# ✨ Features include\n\n\u003e - 🧵 Threading support for faster crawling\n\u003e - ⏯️ Continue scraping where you left off\n\u003e - ⏬ Set the max depth of children you wish to crawl\n\u003e - 📄 Support for tables, images, etc.\n\u003e - ✅ Validates URLs, HTML, filepaths\n\u003e - ⚙️ Configure list of valid base paths or base domains\n\u003e - 🍲 Uses BeautifulSoup to parse HTML\n\u003e - 🪵 Verbose logging option\n\u003e - 👩‍💻 Ready-to-go CLI interface\n\u003cbr\u003e\n\n# 🏗️ Use cases\n- RAG (retrieval augmented generation) - my primary usecase, use this to normalize large documents and chunk by header, pargraph or sentence\n- 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\u0026A pairs\n- Agent knowledge - Leverage this with [autogen](https://github.com/microsoft/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\n- 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\n- many more ..\n\n\u003cbr\u003e\u003cbr\u003e\n\n# 🚀 Get started\n\nIf you wish to simply use it in the CLI, you can run the following command:\n\nInstall the package\n```\npip install markdown-crawler\n```\n\nExecute the CLI\n```\nmarkdown-crawler -t 5 -d 3 -b ./markdown https://en.wikipedia.org/wiki/Morty_Smith\n```\n\nTo run from the github repo, once you have it checked out:\n```\npip install .\nmarkdown-crawler -t 5 -d 3 -b ./markdown https://en.wikipedia.org/wiki/Morty_Smith\n```\n\nOr use the library in your own code:\n```\nfrom markdown_crawler import md_crawl\nurl = 'https://en.wikipedia.org/wiki/Morty_Smith'\nmd_crawl(url, max_depth=3, num_threads=5, base_path='markdown')\n```\n\u003cbr\u003e\u003cbr\u003e\n\n# ⚠️  Requirements\n- Python 3.x\n- BeautifulSoup4\n- requests\n- markdownify\n\n\u003cbr\u003e\u003cbr\u003e\n# 🔍 Usage\n\nThe following arguments are supported\n```\nusage: markdown-crawler [-h] [--max-depth MAX_DEPTH] [--num-threads NUM_THREADS] [--base-path BASE_PATH] [--debug DEBUG]\n                  [--target-content TARGET_CONTENT] [--target-links TARGET_LINKS] [--valid-paths VALID_PATHS]\n                  [--domain-match DOMAIN_MATCH] [--base-path-match BASE_PATH_MATCH]\n                  [--links ]\n                  base-url\n```\n\n\u003cbr\u003e\u003cbr\u003e\n\n# 📝 Example\nTake a look at [example.py](https://github.com/paulpierre/markdown-crawler/blob/main/example.py) for an example\nimplementation of the library. In this configuration we set:\n- `max_depth` to 3. We will crawl the base URL and 3 levels of children\n- `num_threads` to 5. We will use 5 parallel(ish) threads to crawl the website\n- `base_dir` to `markdown`. We will save the markdown files in the `markdown` directory\n- `valid_paths` an array of valid relative URL paths. We will only crawl pages that are in this list and base path\n- `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\n- `is_domain_match` to `False`. We will only crawl pages that are in the same domain as the base URL\n- `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\n- `is_debug` to True. We will print out verbose logging\n\u003cbr\u003e\u003cbr\u003e\n\nAnd when we run it we can view the progress\n\u003cbr\u003e\n\u003e ![cli](https://github.com/paulpierre/markdown-crawler/blob/main/img/ss_crawler.png?raw=true)\n\nWe can see the progress of our files in the `markdown` directory locally\n\u003e ![md](https://github.com/paulpierre/markdown-crawler/blob/main/img/ss_dir.png?raw=true)\n\nAnd we can see the contents of the HTML converted to markdown\n\u003e ![md](https://github.com/paulpierre/markdown-crawler/blob/main/img/ss_markdown.png?raw=true)\n\n\u003cbr\u003e\u003cbr\u003e\n# ❤️ Thanks \nIf you have any issues, please feel free to open an issue or submit a PR. You can reach me via DM on Twitter/X.\n\n  - Follow me on [Twitter / X](https://x.com/paulpierre)\n  - Give me a ⭐ on [Github](https://github.com/paulpierre)\n\n\n\u003cbr\u003e\u003cbr\u003e\n# ⚖️ License\nMIT License\nCopyright (c) 2023 Paul Pierre\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n\n\u003cbr\u003e\u003cbr\u003e\n\n###  markdownify credits\n`markdown_crawler` makes use of markdownify by Matthew Tretter. The original source code can be found [here](https://github.com/matthewwithanm/python-markdownify). It is licensed under the [MIT license](https://github.com/matthewwithanm/python-markdownify/blob/develop/LICENSE).","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpaulpierre%2Fmarkdown-crawler","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpaulpierre%2Fmarkdown-crawler","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpaulpierre%2Fmarkdown-crawler/lists"}