Skip to main content

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

  • --debug or -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

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

mdscraper-0.1.0.tar.gz (14.4 kB view details)

Uploaded Source

Built Distribution

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

mdscraper-0.1.0-py3-none-any.whl (9.1 kB view details)

Uploaded Python 3

File details

Details for the file mdscraper-0.1.0.tar.gz.

File metadata

  • Download URL: mdscraper-0.1.0.tar.gz
  • Upload date:
  • Size: 14.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.1

File hashes

Hashes for mdscraper-0.1.0.tar.gz
Algorithm Hash digest
SHA256 e76132d1d131817f1ee50419727faad531554a816295a68e75302ce3e4c7785f
MD5 af0cb68060cdb5cee9da3e1ad929e789
BLAKE2b-256 928b27d5a3f8b3821c341134eba157e996485bbe81c65b418aaba00e5c985f99

See more details on using hashes here.

File details

Details for the file mdscraper-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: mdscraper-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 9.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.1

File hashes

Hashes for mdscraper-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 26a62f0685e69210e4988319462ebecef7dd616e7f3804349094a916075de27b
MD5 566a7a6fc02325b1f4c2d505121a8fa7
BLAKE2b-256 7ec5f12562649ffb3c558a8bb5e9c17c51d641f1b4598532374aeed49dd48888

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