Skip to main content

mdfetch

A Python library that extracts article content from web platforms and returns it as clean Markdown.

Install

pip

pip install mdfetch

Homebrew (macOS / Linux)

brew install stn1slv/tap/md-fetch

No Python environment setup required.

CLI Usage

You can use the built-in md-fetch command directly from your terminal:

# Fetch and print Markdown to standard output
md-fetch https://medium.com/example/article

# Fetch and save Markdown to a file
md-fetch https://dev.to/example/article --output article.md

# Fallback to Tavily API if the primary extractor fails (requires TAVILY_API_KEY)
export TAVILY_API_KEY="tvly-..."
md-fetch https://example.com/unsupported-blog --tavily-fallback

# List all supported platforms (no URL or network needed)
md-fetch --list-platforms

Python Usage

from mdfetch import extract

# Works with any supported platform — just pass the URL
markdown = extract("https://medium.com/some-publication/article-slug-abc123")
markdown = extract("https://dev.to/username/article-slug")
markdown = extract("https://example.substack.com/p/article-slug")
markdown = extract("https://thenewstack.io/article-slug")
markdown = extract("https://dzone.com/articles/article-slug")
markdown = extract("https://boomi.com/blog/article-slug")
markdown = extract("https://konghq.com/blog/category/article-slug")

# Fallback to Tavily API if the primary extractor fails (requires TAVILY_API_KEY env var).
# This also covers sites that block md-fetch with bot protection (AccessBlockedError).
markdown = extract("https://example.com/unsupported-blog", tavily_fallback=True)
print(markdown)

Error handling

from mdfetch import (
    extract,
    InvalidURLError,
    UnsupportedPlatformError,
    UnsupportedContentTypeError,
    FetchError,
    HTTPStatusError,
    AccessBlockedError,
    EmptyContentError,
    MissingAPIKeyError,
)

url = "https://medium.com/some-publication/article-slug-abc123"

try:
    markdown = extract(url)
except InvalidURLError as e:
    print(f"Bad URL: {e.message}")
except UnsupportedPlatformError as e:
    print(f"Platform not supported: {e.message}")
except UnsupportedContentTypeError as e:
    print(f"Not an article page: {e.message}")
except AccessBlockedError as e:  # subclass of HTTPStatusError, so catch it first
    print(f"Blocked by bot protection: {e.message}")
except HTTPStatusError as e:
    print(f"HTTP {e.status_code}: {e.message}")
except FetchError as e:
    print(f"Network error: {e.message}")
except EmptyContentError as e:
    print(f"No content: {e.message}")
except MissingAPIKeyError as e:
    print(f"Missing API Key: {e.message}")

Supported platforms

Platform Domains
Medium medium.com, *.medium.com
dev.to dev.to
Substack substack.com, *.substack.com
The New Stack thenewstack.io (may be blocked by Cloudflare bot protection; raises AccessBlockedError)
DZone dzone.com
Boomi boomi.com
Kong konghq.com

Development

Requires uv.

make setup        # install dependencies
make test         # run unit tests
make integration  # run integration tests (requires network access)
make lint         # ruff check
make format       # ruff format
make build        # build wheel + sdist
make upgrade-deps # upgrade all dependencies
make clean        # remove build artifacts

Requirements

  • Python 3.12+

Metadata

Release files for mdfetch 0.9.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mdfetch 0.9.6
File Size Uploaded Provenance Actions
mdfetch-0.9.6.tar.gz 518.1 kB With provenance Details for mdfetch-0.9.6.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for mdfetch 0.9.6
File Interpreter ABI Platform Actions
mdfetch-0.9.6-py3-none-any.whl Python 3 none any Details for mdfetch-0.9.6-py3-none-any.whl

Total release size: 539.9 kB

Release files / mdfetch-0.9.6.tar.gz

Download URL mdfetch-0.9.6.tar.gz
Size 518.1 kB
Tags Source
SHA-256 checksum
How to use checksums
d1546fa8742e478899671707c8d602f2864d70cc4034b360877d5fb292a61f28
BLAKE2b-256 checksum
How to use checksums
6aad02ee9fb9548347fdfbb25ac39a42bc742748308f36dac060392a823e8141
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 7, 2026.

Transparency log

Release files / mdfetch-0.9.6-py3-none-any.whl

Download URL mdfetch-0.9.6-py3-none-any.whl
Size 21.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c9cdc5516bd4163fb40a0d0ecbe2c89c438dec4f4d79fa7de7647bbaada2e1b4
BLAKE2b-256 checksum
How to use checksums
e0f68b8a169701850bbbadbd2bee5a11f694fa76392489108cb8fd6d3cbfe273
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 7, 2026.

Transparency log

Security for mdfetch 0.9.6

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for mdfetch-0.9.6.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 7, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page