A tool to fetch webpages and convert their content to clean Markdown format for LLM processing
Project description
MDScraper
A specialized tool for extracting clean, structured content from webpages and converting it to Markdown format. Ideal for preparing web content for LLM embeddings and semantic search applications.
Features
- Clean and normalize web content for optimal LLM processing
- Extract relevant content while filtering out noise, navigation, ads, and irrelevant elements
- Transform HTML content into consistent, well-structured Markdown format
- Process single URLs or batch process multiple URLs from a file
- Intelligent content detection for various webpage layouts
- Options to ignore images and links to reduce token usage in embeddings
- Option to add extra spacing before headings for improved document structure
- Debug mode for troubleshooting extraction issues
Installation
Option 1: Install from PyPI
uv pip install mdscraper
Option 2: Install from source
First, ensure you have UV installed. If not, install it following the official UV installation guide:
curl -LsSf https://astral.sh/uv/install.sh | sh
Then clone and install the repository:
git clone https://github.com/yourusername/mdscraper.git
cd mdscraper
uv pip install .
Usage
Process a single URL
mdscraper --url https://example.com --output example.md
Process multiple URLs from a file
Create a text file with one URL per line, then run:
mdscraper --file urls.txt --outdir output_directory
Additional options
--debugor-d: Enable debug mode for more information--no-images: Ignore all images in the content--no-links: Ignore all links in the content--extra-heading-space LEVELS: Add newlines before specific heading levels for better readability. LEVELS can be:all: Add spacing to all heading levels (h1-h6)1,2,3: Comma-separated list of specific heading levels to apply spacing to
--prepend-source-link: Prepend source link in markdown file
Development
Running Tests
To run the test suite, first ensure you have the development dependencies installed:
uv pip install -e ".[dev]"
Then run the tests:
# Run tests without coverage
pytest tests/
# Run tests with coverage report
pytest tests/ --cov
The coverage report will show you which parts of the code are covered by tests and which lines are missing coverage.
License
MIT
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mdscraper-0.1.1.tar.gz.
File metadata
- Download URL: mdscraper-0.1.1.tar.gz
- Upload date:
- Size: 14.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c6abfc5c4fa4502395906d51062915c33cbb30e040376b49caa4ee344329e140
|
|
| MD5 |
86434dc555ea33814fb0e9d17193f87d
|
|
| BLAKE2b-256 |
07ffd8d4ea1b090eeb3e332410519a9f948f7953f153e9fdeaa043cbe31ecb61
|
File details
Details for the file mdscraper-0.1.1-py3-none-any.whl.
File metadata
- Download URL: mdscraper-0.1.1-py3-none-any.whl
- Upload date:
- Size: 9.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
af8e6471c80102576dda1f759c1de4670724c3138a19f24e6f6ff9b41adb29d4
|
|
| MD5 |
ad72837822ccd4360747bfdf77a7d9bc
|
|
| BLAKE2b-256 |
658e292ee89215b0442a21b9c72342a2071d64e1e6e208a90590b4a02fde4ee5
|