Browser

News To Markdown

Try it

输入文章 URL,输出干净的 Markdown 正文。支持17个平台专项优化(头条、微信公众号、知乎、36kr、虎嗅、华尔街见闻、澎湃、InfoQ 等),双引擎提取、图片本地化、三层抓取策略。常与 browser-web-search skill 配合:先用 bws 搜索拿到 url 列表,再逐篇调用本 skil...

What it does

输入文章 URL,输出干净的 Markdown 正文。17 个平台专项优化,为 AI Agent 而生。

The skill document

news-to-markdown Skill

输入文章 URL,输出干净的 Markdown 正文。17 个平台专项优化,为 AI Agent 而生。

🎯 核心特点

  • 📰 17 个平台专项适配 — 头条、微信、知乎、36kr、虎嗅、华尔街见闻、澎湃、InfoQ 等
  • 🔄 三层抓取策略 — curl → wget → Playwright 自动回退,静态/动态页面均支持
  • 🧠 双引擎提取 — Mozilla Readability + news-extractor-node 智能取优
  • 🖼️ 图片本地化 — 可选将远程图片下载到本地,防止 URL 过期
  • 🎨 无封面自动兜底 — 文章未识别到封面图时,基于标题生成抽象图案占位封面写入 frontmatter cover:,避免下游发布链路(如微信公众号)因缺少封面失败
  • 🔒 固定版本 + 进程内调用scripts/run.js launcher 解析已安装的固定版本 npm 包并在进程内运行,不 fork 子进程、不调用 npx、不在运行时漂移版本

🚀 快速开始

推荐:固定版本 + launcher(无子进程、无版本漂移)

# 一次性安装(每次小版本升级时手动重做一次)
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)里用于一次性试用;常驻使用请走上面的固定版本路径。

npx --yes news-to-markdown@^3.3.1 --url "https://www.toutiao.com/article/123"

🔗 与 browser-web-search 配合使用

最常见的 AI Agent 编排模式:

browser-web-search  →  搜索,产出 URL 列表
news-to-markdown    →  读取正文,产出 Markdown
# 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/searchweixin/searchzhihu/search36kr/searchxiaohongshu/searchhuxiu/searchwallstreetcn/searchthepaper/searchqqnews/searchnetease/searchsina/searchjuejin/searchcsdn/searchcnblogs/searchinfoq/search
  • 🌏 国际文章类:verge/searchars/searchengadget/searchhn/search(外链文章)

注意github/searchreddit/searchx/searchweibo/search 等平台的 bws 结果本身是结构化数据,无需再用本工具提取正文。


📋 支持平台

专项优化平台(17 个)

平台域名专项说明
今日头条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财经正文提取、去高亮 `` 标签
澎湃新闻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 算法。


🔧 命令参数

node scripts/run.js convert --url  [选项]
参数类型说明
--urlstring文章 URL(必填)
--outputstring输出文件路径(默认输出到终端)
--download-imagesflag下载图片到本地(推荐)
--output-dirstring图片输出目录(--download-images 时使用)
--no-metadataflag只要正文,不含标题/作者/时间
--selectorstring自定义内容区域 CSS 选择器
--noisestring移除元素的选择器,逗号分隔
--verboseflag详细日志(调试用)

📋 标准操作流程 (SOP)

操作 1:基础文章转换

场景:用户提供一个文章 URL,要求转换为 Markdown

node scripts/run.js convert \
  --url "https://www.toutiao.com/article/123" \
  --output article.md

操作 2:转换并下载图片(推荐)

场景:需要保留图片,或后续要发布到微信公众号

node scripts/run.js convert \
  --url "https://www.toutiao.com/article/123" \
  --download-images \
  --output-dir ./article
# 输出:./article/article.md + ./article/images/*.jpg

头条、微信等平台的图片 URL 包含签名,数小时后失效。下载到本地可避免此问题。


操作 3:只提取正文

场景:用户说"只要文章内容,不要标题作者等信息"

node scripts/run.js convert \
  --url "https://36kr.com/p/xxx" \
  --no-metadata

操作 4:批量处理多篇文章

场景:配合 bws 搜索结果批量提取

# 先搜索
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

操作 5:自定义提取(去噪 / 指定区域)

场景:提取结果不准,用户要求去掉广告或指定正文区域

# 去掉广告和评论
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"

操作 6:调试失败页面

场景:抓取或提取失败,需要排查

node scripts/run.js convert \
  --url "https://example.com/article" \
  --verbose

常见原因与解决方案

问题原因解决方案
抓取失败需要 JS 渲染自动使用 Playwright(需提前安装)
内容为空选择器不匹配使用 --selector 指定内容区域
图片显示不了URL 过期使用 --download-images
反爬拦截无头浏览器被检测知乎已内置 Chrome UA,其他平台视情况处理

可选安装 Playwright 浏览器(动态页面支持):

npx playwright install chromium

🎓 示例对话

用户:帮我把这篇虎嗅文章转成 Markdown,图片也要保存

node scripts/run.js convert \
  --url "https://www.huxiu.com/article/xxx.html" \
  --download-images \
  --output-dir ./huxiu-article

用户:搜索头条最新 3 篇关于 AI Agent 的文章,并获取每篇正文

# Step 1: 搜索
bws site toutiao/search "AI Agent" --count 3

# Step 2: 逐篇提取(对每个 url 执行)
node scripts/run.js convert --url "" --output ".md"

用户:只要这篇知乎文章的正文,不要其他信息

node scripts/run.js convert \
  --url "https://www.zhihu.com/p/xxx" \
  --no-metadata

⚠️ 安全与版权

两条调用路径(推荐 / 备选)

  1. 🟢 推荐:Skill 插件 / launcher 路径node scripts/run.js convert …) 在进程内 require() 已固定版本的 npm 包,不 fork 子进程、不调用 npx、不在 ^3.3.1 范围内漂移版本。一次性安装:

    npm install -g news-to-markdown@3.3.1
    

    未安装时,launcher 会以可操作的 JSON 错误提示退出,不会自动安装、不会回退到子进程。该选择消除了 child_process 调用面与运行时版本漂移面,匹配 codeguard-0-supply-chain-securitycodeguard-0-input-validation-injection 的硬化要求。

  2. 🟡 备选: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 浏览器二进制

第三层抓取策略(动态页面回退)依赖 playwright。首次 npx playwright install chromium 会从 Microsoft / Google 的 CDN 下载 Chromium 二进制(~150 MB)到 ~/Library/Caches/ms-playwright/(macOS)或 ~/.cache/ms-playwright/(Linux)。该步骤会执行远端二进制到本地,建议:

  • 仅在确实需要动态页面渲染时再装;多数静态页面(头条、澎湃、华尔街见闻、CSDN、博客园 等)走 curl/wget 路径即可
  • 在 OS 级沙箱、容器或受限用户下运行(避免赋予 Playwright 进程额外文件系统/网络权限)
  • 抓取触发反爬时,先确认目标站允许内容获取再启用动态渲染

版权提示

本工具默认用于个人学习和内容归档。对外发布时,请保留来源链接和作者信息,并确认来源站点的版权声明与转载政策。


📝 维护说明

  • 版本: 3.3.1
  • 最后更新: 2026-04-28
  • 维护者: Ping Si
  • 许可证: MIT

📚 参考资料

Related skills

Adaptive web scraping in Python that bypasses anti-bot systems and scales from single requests to concurrent crawls.

by d4vinci399 installs28 stars

Persistent browser and Electron interaction through `js_repl` for fast iterative UI debugging.

by OpenAI27.5k stars

Toolkit for interacting with and testing local web applications using Playwright. Supports verifying frontend functionality, debugging UI behavior, capturing browser screenshots, and viewing browser l

by Anthropic177.2k stars

playwright

Official

Use when the task requires automating a real browser from the terminal (navigation, form filling, snapshots, screenshots, data extraction, UI-flow debugging) via `playwright-cli` or the bundled wrappe

by OpenAI27.5k stars

More from sipingme

Browse all skills

Turn article URLs or local documents into WeChat Official Account drafts, with optional AI rewriting.

by sipingme40 installs

发布 Markdown 文章到微信公众号,支持草稿管理、多主题、智能图片处理、自动封面图。推荐与 news-to-markdown-skill 配合使用实现一键转载(支持本地图片)。

by sipingme56 installs

基于 markdown-ai-rewriter 的 Markdown AI 改写 Skill(保留结构、章节/全文模式、多模型、图片生成、视频生成、音乐生成)

by sipingme30 installs1 stars

一行命令搜遍全网 — 55 个平台 91+ 个命令,头条、知乎、豆瓣、YouTube、GitHub、Reddit、Hacker News 等。专为 OpenClaw 设计,复用浏览器登录态,返回结构化 JSON,天然适配 AI Agent 工具调用。

by sipingme41 installs

通过 MCP 协议操作今日头条平台,支持内容发布、账号管理等功能

by sipingme28 installs

用 LLM 友好的方式控制用户已登录的真实 Chrome(CDP)。一行命令在当前标签页跑 JS、点击、滚动、截图、读 DOM、填表、上传文件——共享 cookie/session/登录态,跨 Python 与 TypeScript Agent 操作同一个浏览器。基于 browser-use/browser-ha...

by sipingme17 installs1 stars