输入文章 URL,返回干净 Markdown。支持17个平台(头条、微信公众号、知乎、36kr、虎嗅、华尔街见闻、澎湃、InfoQ 等)专项优化,双引擎提取、图片本地化、三层抓取策略。常与 browser‑web‑search skill配合:先用 bws 搜索获取 url 列表,再逐篇调用本 skill 提取正文。
输入文章 URL,输出干净的 Markdown 正文。17 个平台专项优化,为 AI Agent 而生。
cover:,避免下游发布链路(如微信公众号)因缺少封面失败scripts/run.js launcher 解析已安装的固定版本 npm 包并在进程内运行,不 fork 子进程、不调用 npx、不在运行时漂移版本bash
# 一次性安装(每次小版本升级时手动重做一次)
npm install -g news-to-markdown@3.3.1
# 之后通过 launcher 调用(args 经 allow-list 校验,URL/输出参数透传到进程内 CLI)
node scripts/run.js convert --url "https://www.toutiao.com/article/123"
node scripts/run.js convert --url "https://mp.weixin.qq.com/s/xxx" --output article.md
node scripts/run.js convert --url "https://www.toutiao.com/article/123" \
--download-images --output-dir ./article
node scripts/run.js convert --url "https://www.zhihu.com/p/xxx" --no-metadata
npx --yes(一次性试用 / 临时沙箱环境)#⚠️ 供应链风险:
npx --yes news-to-markdown@^3.3.1在 每次调用时 从 npm 解析并执行落在^3.3.1范围内的最新版本,无 lockfile、无完整性校验。仅建议在隔离环境(容器、临时 VM)里用于一次性试用;常驻使用请走上面的固定版本路径。
bash
npx --yes news-to-markdown@^3.3.1 --url "https://www.toutiao.com/article/123"
最常见的 AI Agent 编排模式:
text
browser-web-search → 搜索,产出 URL 列表
news-to-markdown → 读取正文,产出 Markdown
bash
# Step 1:用 bws 搜索,拿到文章 URL 列表
bws site toutiao/search "ai agent" --count 3
# Step 2:对每个 URL 提取正文
node scripts/run.js convert --url "https://www.toutiao.com/article/111"
node scripts/run.js convert --url "https://www.toutiao.com/article/222"
node scripts/run.js convert --url "https://www.toutiao.com/article/333"
适用搜索命令(browser-web-search 0.4.2,30 个平台):
toutiao/search、 weixin/search、 zhihu/search、 36kr/search、 xiaohongshu/search、 huxiu/search、 wallstreetcn/search、 thepaper/search、 qqnews/search、 netease/search、 sina/search、 juejin/search、 csdn/search、 cnblogs/search、 infoq/searchverge/search、 ars/search、 engadget/search、 hn/search(外链文章)注意:
github/search、reddit/search、x/search、weibo/search等平台的 bws 结果本身是结构化数据,无需再用本工具提取正文。
平台域名专项说明今日头条toutiao.com标题规范化、 data-src 图片、列表修复微信公众号mp.weixin.qq.com#js_content 提取、移动端 UA 回退小红书xiaohongshu.com.note-content 提取、懒加载图片知乎zhihu.com真实 Chrome 绕过 zse-ck 反爬36kr36kr.com自动转移动端 URL 绕过反爬虎嗅huxiu.com正文区域提取、懒加载图片修复华尔街见闻wallstreetcn.com财经正文提取、去高亮 <em> 标签澎湃新闻thepaper.cn.news_txt 正文区域提取InfoQinfoq.cn / infoq.com技术文章正文提取Bilibili 专栏bilibili.com/read/ 路径文章提取掘金juejin.cn代码块与正文提取CSDNcsdn.net去广告侧边栏、 #content_views 提取博客园cnblogs.com技术博客正文提取简书jianshu.com文章正文提取SegmentFaultsegmentfault.com技术问答正文提取开源中国oschina.net资讯正文提取人人都是产品经理woshipm.com产品文章正文提取
其余平台(The Verge、Ars Technica、Engadget 等英文站)走通用 Readability 算法。
bash
node scripts/run.js convert --url <URL> [选项]
参数类型说明--urlstring文章 URL(必填)--outputstring输出文件路径(默认输出到终端)--download-imagesflag下载图片到本地(推荐)--output-dirstring图片输出目录( --download-images 时使用)--no-metadataflag只要正文,不含标题/作者/时间--selectorstring自定义内容区域 CSS 选择器--noisestring移除元素的选择器,逗号分隔--verboseflag详细日志(调试用)
场景:用户提供一个文章 URL,要求转换为 Markdown
bash
node scripts/run.js convert \
--url "https://www.toutiao.com/article/123" \
--output article.md
场景:需要保留图片,或后续要发布到微信公众号
bash
node scripts/run.js convert \
--url "https://www.toutiao.com/article/123" \
--download-images \
--output-dir ./article
# 输出:./article/article.md + ./article/images/*.jpg
头条、微信等平台的图片 URL 包含签名,数小时后失效。下载到本地可避免此问题。
场景:用户说"只要文章内容,不要标题作者等信息"
bash
node scripts/run.js convert \
--url "https://36kr.com/p/xxx" \
--no-metadata
场景:配合 bws 搜索结果批量提取
bash
# 先搜索
bws site zhihu/search "大模型" --count 5 --jq '[.items[].url]'
# 再逐篇提取
for url in "${urls[@]}"; do
node scripts/run.js convert --url "$url" --output "articles/$(echo $url | md5sum | cut -c1-8).md"
done
场景:提取结果不准,用户要求去掉广告或指定正文区域
bash
# 去掉广告和评论
node scripts/run.js convert \
--url "https://example.com/article" \
--noise ".ad,.sidebar,.comments"
# 指定内容区域
node scripts/run.js convert \
--url "https://example.com/article" \
--selector "article.main-content"
场景:抓取或提取失败,需要排查
bash
node scripts/run.js convert \
--url "https://example.com/article" \
--verbose
常见原因与解决方案:
问题原因解决方案抓取失败需要 JS 渲染自动使用 Playwright(需提前安装)内容为空选择器不匹配使用 --selector 指定内容区域图片显示不了URL 过期使用 --download-images反爬拦截无头浏览器被检测知乎已内置 Chrome UA,其他平台视情况处理
可选安装 Playwright 浏览器(动态页面支持):
bash
npx playwright install chromium
用户:帮我把这篇虎嗅文章转成 Markdown,图片也要保存
bash
node scripts/run.js convert \
--url "https://www.huxiu.com/article/xxx.html" \
--download-images \
--output-dir ./huxiu-article
用户:搜索头条最新 3 篇关于 AI Agent 的文章,并获取每篇正文
bash
# Step 1: 搜索
bws site toutiao/search "AI Agent" --count 3
# Step 2: 逐篇提取(对每个 url 执行)
node scripts/run.js convert --url "<url>" --output "<title>.md"
用户:只要这篇知乎文章的正文,不要其他信息
bash
node scripts/run.js convert \
--url "https://www.zhihu.com/p/xxx" \
--no-metadata
🟢 推荐:Skill 插件 / launcher 路径( node scripts/run.js convert …)
在进程内 require() 已固定版本的 npm 包, 不 fork 子进程、不调用 npx、不在 ^3.3.1 范围内漂移版本。一次性安装:
bash
npm install -g news-to-markdown@3.3.1
未安装时,launcher 会以可操作的 JSON 错误提示退出,不会自动安装、不会回退到子进程。该选择消除了 child_process 调用面与运行时版本漂移面,匹配 codeguard-0-supply-chain-security 与 codeguard-0-input-validation-injection 的硬化要求。
🟡 备选: npx --yes 直接终端调用
形如 npx --yes news-to-markdown@^3.3.1 …。 每次调用都会从 npm 拉取并执行落在 ^3.3.1 范围内的最新版本——这是受信范围内的供应链漂移面,没有 lockfile、没有完整性校验。仅建议在隔离环境(一次性容器、临时 VM、沙箱)下做快速试用;不要用于常驻的批处理。
本 Skill 透传到第三方 npm 包,使用前请审计源码:
scripts/run.js 仅放行 SKILL.md 中文档化的子命令与参数(allow-list),并对每个参数做长度上限与控制字符校验后才注入到 CLI 进程的 argv,不会进入 shell。但被透传的目标包本身仍可发起任意网络/磁盘 I/O,建议固定到 3.3.1 之后再做一次源码审阅。
第三层抓取策略(动态页面回退)依赖 playwright。首次 npx playwright install chromium 会从 Microsoft / Google 的 CDN 下载 Chromium 二进制(~150 MB)到 ~/Library/Caches/ms-playwright/(macOS)或 ~/.cache/ms-playwright/(Linux)。该步骤会执行远端二进制到本地,建议:
本工具默认用于个人学习和内容归档。对外发布时,请保留来源链接和作者信息,并确认来源站点的版权声明与转载政策。