name: defuddle
description: 使用 Defuddle 库从任意网页提取主要内容并转换为 Markdown 格式。支持 CLI 和 Node.js 集成,用于内容爬虫、文本处理和自动化任务。
metadata: {"openclaw": {"os": ["darwin", "linux", "win32"], "author": "Honcy Ye", "email": "honcy.ye@gmail.com"}}
使用 Defuddle 库从任意网页提取主要内容并转换为 Markdown 格式。
# 解析 URL 并输出为 Markdown
npx defuddle parse https://example.com/article --markdown
# 解析本地 HTML 文件
npx defuddle parse page.html --markdown
# 输出为 JSON 格式(包含元数据)
npx defuddle parse page.html --json
# 从 URL 提取内容并发送到微信文件传输助手
bash scripts/extract_and_send.sh "https://example.com/article" "文件传输助手"
# 从 URL 提取内容并发送到 Telegram
bash scripts/extract_and_send_telegram.sh "https://example.com/article" <chat_id>
import { JSDOM } from 'jsdom';
import { Defuddle } from 'defuddle/node';
async function extractContent(url) {
const response = await fetch(url);
const html = await response.text();
const dom = new JSDOM(html, { url });
const result = await Defuddle(dom.window.document);
return {
title: result.title,
content: result.content,
markdown: result.contentMarkdown
};
}
scripts/extract_content.sh: 从 URL 提取内容并输出到控制台scripts/extract_and_send.sh: 提取内容并发送到微信scripts/extract_and_send_telegram.sh: 提取内容并发送到 Telegramnpm install -g defuddle
共 1 个版本