Package: markdown-crawler
|                                     |             
 __ `__ \    _` |        __|   __|   _` | \ \  \   /  |   _ \   __| 
 |   |   |  (   |       (     |     (   |  \ \  \ /   |   __/  |    
_|  _|  _| \__._|      \___| _|    \__._|   \_/\_/   _| \___| _|    

---------------------------------
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📝 OverviewThis 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🍲 Uses BeautifulSoup to parse HTML🪵 Verbose logging option👩‍💻 Ready-to-go CLI interface🚀 Get startedIf you wish to simply use it in the CLI, you can run the following command:Install the packagepip install markdown-crawlerExecute the CLImarkdown-crawler -t 5 -d 3 -b ./markdown https://en.wikipedia.org/wiki/Morty_SmithTo 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_SmithOr 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')⚠️  RequirementsPython 3.xBeautifulSoup4requests🔍 UsageThe following arguments are supportedusage: 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]
                  [--domain-match DOMAIN_MATCH] [--base-path-match BASE_PATH_MATCH]
                  [--links ]
                  base-url📝 ExampleTake a look atexample.pyfor an example
implementation of the library. In this configuration we set:max_depthto 3. We will crawl the base URL and 3 levels of childrennum_threadsto 5. We will use 5 parallel(ish) threads to crawl the websitebase_dirtomarkdown. We will save the markdown files in themarkdowndirectoryvalid_pathsan array of valid relative URL paths. We will only crawl pages that are in this list and base pathtarget_contenttodiv#content. We will only crawl pages that have this HTML element using CSS target selectors. You can provide multiple and it will concatenate the resultsis_domain_matchtoFalse. We will only crawl pages that are in the same domain as the base URLis_base_path_matchtoFalse. We will include all URLs in the same domain, even if they don't begin with the base urlis_debugto True. We will print out verbose loggingAnd when we run it we can view the progressWe can see the progress of our files in themarkdowndirectory locallyAnd we can see the contents of the HTML converted to markdown❤️ ThanksIf you have an issues, please feel free to open an issue or submit a PR. You can reach me via DM on Twitter/X.Follow me onTwitter / XGive me a ⭐ onGithub⚖️ LicenseMIT License
Copyright (c) 2023 Paul Pierre
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 creditsmarkdown_crawlermakes use of markdownify by Matthew Tretter. The original source code can be foundhere. It is licensed under theMIT license.