Skip to main content

墨探 (omni-article-markdown)

PyPI Python License PyPI Downloads Docker Pulls Stars

轻松将网页文章(博客、新闻、文档等)转换为 Markdown 格式。

简介

墨探的开发初衷,是为了解决一个问题:如何将来自互联网上各种不同网站的文章内容,精准且高效地转换成统一的Markdown格式。

众所周知,万维网上的网站设计风格迥异,其HTML结构也呈现出千差万别的特点。这种多样性给自动化内容提取和格式转换带来了巨大的困难。要实现一个能够适应各种复杂HTML结构的通用解决方案,并非易事。

我的想法是:从特定的网站开始适配,以点到面,逐步抽取出通用的解决方案,最后尽可能多的覆盖更多网站。

功能介绍

  • 通用网页正文提取:自动识别并提取文章主体,剔除导航、广告、推荐等无关内容
  • 丰富的 HTML 元素转换:标题、列表、表格、图片、代码块、引用等均可正确转换为对应 Markdown 语法
  • 数学公式支持:部分页面的 KaTeX / LaTeX 公式可转换为 Markdown 数学语法
  • 动态渲染与反爬突破:对需要 JS 渲染或有防爬策略的站点,内置浏览器方案获取完整页面
  • 灵活的输出方式:支持输出到 stdout 或直接保存为 Markdown 文件

已适配网站详见 网站兼容列表。

本项目同时提供 Agent Skill(skills/omni-article-markdown/SKILL.md),可安装到 Claude Code、Codex 等 AI 客户端中使用。

安装与升级

# pipx
pipx install omni-article-markdown
pipx upgrade omni-article-markdown

# pip
pip install omni-article-markdown
pip install -U omni-article-markdown

# uv
uv tool install omni-article-markdown
uv tool install omni-article-markdown --upgrade

安装完成后即可使用:

mdcli -h

不想装 Python 环境,也可以用 Docker 镜像(详见 README.docker.md):

docker run --rm caol64/omnimd https://example.com/article

基本用法

仅转换

mdcli https://example.com

保存到当前目录

mdcli https://example.com -s

保存到指定路径

mdcli https://example.com -s /home/user/

限制输出规模(适合 AI Agent 调用,防止长文撑爆上下文)

# 截断到约 800 tokens(分段启发式估算,误差约 ±10%),段落边界收尾并追加 …[truncated] 标记
mdcli https://example.com --truncate
mdcli https://example.com --truncate 1500

纯 Markdown 源原样输出

源本身就是 Markdown(如 GitHub raw 链接)时,跳过 HTML 解析与转换,逐字节原样输出:

mdcli https://raw.githubusercontent.com/caol64/omni-article-markdown/refs/heads/main/README.md

架构说明

墨探主要分为三个模块:

  • Reader 模块的功能是读取整个网页内容
  • Extractor 模块的功能是提取正文内容,清理无用数据
  • Parser 模块的功能是将 HTML 转换为 Markdown

贡献与反馈

赞助

如果你觉得墨探对你有帮助,可以给我家猫咪买点罐头 ❤️

https://yuzhi.tech/sponsor

License

MIT License

Metadata

Release files for omni-article-markdown 0.2.5

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

Source distribution (sdist)

Source distribution for omni-article-markdown 0.2.5
File Size Uploaded Provenance Actions
omni_article_markdown-0.2.5.tar.gz 47.5 kB Without provenance Details for omni_article_markdown-0.2.5.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for omni-article-markdown 0.2.5
File Interpreter ABI Platform Actions
omni_article_markdown-0.2.5-py3-none-any.whl Python 3 none any Details for omni_article_markdown-0.2.5-py3-none-any.whl

Total release size: 121.7 kB

Release files / omni_article_markdown-0.2.5.tar.gz

Download URL omni_article_markdown-0.2.5.tar.gz
Size 47.5 kB
Tags Source
SHA-256 checksum
How to use checksums
9c39ca0f45e65937da376f37ab0b994510b001f1cc76e054911eb32705178b8f
BLAKE2b-256 checksum
How to use checksums
bfa0fb05911f9c13f1f9805785c5f34ddb5500467fe4bb77ce4c0797aa7373e9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / omni_article_markdown-0.2.5-py3-none-any.whl

Download URL omni_article_markdown-0.2.5-py3-none-any.whl
Size 74.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
425d68cb9f7cc80fbd2b5bf7525ec74cfa2d331825d281102a66ca62b11b5db6
BLAKE2b-256 checksum
How to use checksums
3b7647b84c552740803e862694e3da74259cfc6a1e09bd7df3f1a3bab7530701
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for omni-article-markdown 0.2.5

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

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