Skip to main content

Extract article content from web platforms and return it as clean Markdown.

Project description

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

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")
print(markdown)

Error handling

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

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 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}")

Supported platforms

Platform Domains
Medium medium.com, *.medium.com
dev.to dev.to
Substack substack.com, *.substack.com
The New Stack thenewstack.io
DZone dzone.com
Boomi boomi.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+

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

mdfetch-0.6.0.tar.gz (396.4 kB view details)

Uploaded Source

Built Distribution

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

mdfetch-0.6.0-py3-none-any.whl (17.5 kB view details)

Uploaded Python 3

File details

Details for the file mdfetch-0.6.0.tar.gz.

File metadata

  • Download URL: mdfetch-0.6.0.tar.gz
  • Upload date:
  • Size: 396.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for mdfetch-0.6.0.tar.gz
Algorithm Hash digest
SHA256 72968c11a3d0b9795dcf1c01cd44ee4f084b1de68c5ba4eab9a01b8f0679ac96
MD5 668c9ba4ad34150cd5122ba149b55e17
BLAKE2b-256 29db2d5d91ea4d789c60e2aa70b93b3b562be696cf64290a4047b10d1eb52dea

See more details on using hashes here.

Provenance

The following attestation bundles were made for mdfetch-0.6.0.tar.gz:

Publisher: publish.yml on stn1slv/md-fetch

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mdfetch-0.6.0-py3-none-any.whl.

File metadata

  • Download URL: mdfetch-0.6.0-py3-none-any.whl
  • Upload date:
  • Size: 17.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for mdfetch-0.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 366293340f5842b39995b512deafa945ad46847862cab906103816ec9c44c26b
MD5 3e59afdbece1e91d6cb30cd96f9eb71c
BLAKE2b-256 c1548d4cf6423907054b0c80fd33bc123fa86d88bc1c6c7c07cb6c977ce585bd

See more details on using hashes here.

Provenance

The following attestation bundles were made for mdfetch-0.6.0-py3-none-any.whl:

Publisher: publish.yml on stn1slv/md-fetch

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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