article-extractor
从 URL(博客文章、文章、教程)中提取清晰的文章内容,并保存为可读文本。当用户想要从 URL 下载、提取或保存不含广告、导航或杂乱信息的文章/博客文章时使用。
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
القائمة
从 URL(博客文章、文章、教程)中提取清晰的文章内容,并保存为可读文本。当用户想要从 URL 下载、提取或保存不含广告、导航或杂乱信息的文章/博客文章时使用。
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
استنادا إلى تصنيف SOC المهني
查询A股实时行情、历史数据、技术指标、事件、资金面与个股行业信息。Use when 用户提到股票代码、板块、技术分析、财务指标、指数成分、交易日历、宏观数据或个股所属行业。
A股模拟盘交易与回测技能。Use when 用户要启动模拟仓服务、创建多账户、下限价单/市价单、撤单、查询持仓资金、验证涨跌停成交逻辑或运行A股回测。
A 股主板流动性池内按趋势回踩(trend_pullback)产出买入候选与持仓卖出信号;另有 realtime_quotes 批量拉取现价快照。供下单前决策;不跑回测、不自动下单。Use when 用户要选股、看实时报价、判断买卖信号或检查持仓是否触发离场条件。
基于退哥短线交易规则的A股场景化决策技能。Use when 用户要按交易场景查看短线规则、做选股、判断趋势回踩、涨停回调、连板接力、洗盘结束、卖出失效或仓位纪律。
Multi-dimensional code review with structured reports. Analyzes correctness, readability, performance, security, testing, and architecture, and respects project-specific conventions defined in dreame_code.md. Triggers on "review code", "code review", "审查代码", "代码审查".
Provides comprehensive code review guidance for React 19, Vue 3, Rust, TypeScript, Java, Python, and C/C++. Helps catch bugs, improve code quality, and give constructive feedback. Use when: reviewing pull requests, conducting PR reviews, code review, reviewing code changes, establishing review standards, mentoring developers, architecture reviews, security audits, checking code quality, finding bugs, giving feedback on code.
| name | article-extractor |
| description | 从 URL(博客文章、文章、教程)中提取清晰的文章内容,并保存为可读文本。当用户想要从 URL 下载、提取或保存不含广告、导航或杂乱信息的文章/博客文章时使用。 |
| allowed-tools | Bash,Write |
此技能可以从网页文章和博客文章中提取主要内容,移除导航、广告、新闻订阅框和其他冗余信息。保存清晰、可读的文本。
当用户执行以下操作时激活:
按以下顺序检查文章提取工具:
command -v reader
如果未安装:
npm install -g @mozilla/readability-cli
# 或
npm install -g reader-cli
command -v trafilatura
如果未安装:
pip3 install trafilatura
如果没有可用工具,使用基础的 curl + 文本提取(虽然不太可靠,但仍然有效)
# 提取文章
reader "URL" > article.txt
优点:
# 提取文章
trafilatura --URL "URL" --output-format txt > article.txt
# 或者使用更多选项
trafilatura --URL "URL" --output-format txt --no-comments --no-tables > article.txt
优点:
选项:
--no-comments: 跳过评论区域--no-tables: 跳过数据表格--precision: 优先保证准确度而非法召回率--recall: 提取更多内容(可能包含一些噪点)# 下载并提取基础内容
curl -s "URL" | python3 -c "
from html.parser import HTMLParser
import sys
class ArticleExtractor(HTMLParser):
def __init__(self):
super().__init__()
self.in_content = False
self.content = []
self.skip_tags = {'script', 'style', 'nav', 'header', 'footer', 'aside'}
self.current_tag = None
def handle_starttag(self, tag, attrs):
if tag not in self.skip_tags:
if tag in {'p', 'article', 'main', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6'}:
self.in_content = True
self.current_tag = tag
def handle_data(self, data):
if self.in_content and data.strip():
self.content.append(data.strip())
def get_content(self):
return '\n\n'.join(self.content)
parser = ArticleExtractor()
parser.feed(sys.stdin.read())
print(parser.get_content())
" > article.txt
注意: 这种方法可靠性较低,但在没有依赖的情况下可以使用。
提取用于文件名的标题:
# reader 输出带有标题的 markdown,标题在第一行
TITLE=$(reader "URL" | head -n 1 | sed 's/^# //')
# 获取包含标题的元数据
TITLE=$(trafilatura --URL "URL" --json | python3 -c "import json, sys; print(json.load(sys.stdin)['title'])")
TITLE=$(curl -s "URL" | grep -oP '<title>\K[^<]+' | sed 's/ - .*//' | sed 's/ | .*//')
为文件系统清理标题:
# 获取标题
TITLE="来自网站的文章标题"
# 清理文件系统不兼容字符(移除特殊字符,限制长度)
FILENAME=$(echo "$TITLE" | tr '/' '-' | tr ':' '-' | tr '?' '' | tr '"' '' | tr '<' '' | tr '>' '' | tr '|' '-' | cut -c 1-100 | sed 's/ *$//')
# 添加扩展名
FILENAME="${FILENAME}.txt"
ARTICLE_URL="https://example.com/article"
# 检查工具
if command -v reader &> /dev/null; then
TOOL="reader"
echo "使用 reader (Mozilla Readability)"
elif command -v trafilatura &> /dev/null; then
TOOL="trafilatura"
echo "使用 trafilatura"
else
TOOL="fallback"
echo "使用备选方法(可能不够准确)"
fi
# 提取文章
case $TOOL in
reader)
# 获取内容
reader "$ARTICLE_URL" > temp_article.txt
# 获取标题(markdown 中 # 之后的第一行)
TITLE=$(head -n 1 temp_article.txt | sed 's/^# //')
;;
trafilatura)
# 从元数据中获取标题
METADATA=$(trafilatura --URL "$ARTICLE_URL" --json)
TITLE=$(echo "$METADATA" | python3 -c "import json, sys; print(json.load(sys.stdin).get('title', 'Article'))")
# 获取纯净内容
trafilatura --URL "$ARTICLE_URL" --output-format txt --no-comments > temp_article.txt
;;
fallback)
# 获取标题
TITLE=$(curl -s "$ARTICLE_URL" | grep -oP '<title>\K[^<]+' | head -n 1)
TITLE=${TITLE%% - *} # 移除站点名称
TITLE=${TITLE%% | *} # 移除站点名称(另一种格式)
# 获取内容(基础提取)
curl -s "$ARTICLE_URL" | python3 -c "
from html.parser import HTMLParser
import sys
class ArticleExtractor(HTMLParser):
def __init__(self):
super().__init__()
self.in_content = False
self.content = []
self.skip_tags = {'script', 'style', 'nav', 'header', 'footer', 'aside', 'form'}
def handle_starttag(self, tag, attrs):
if tag not in self.skip_tags:
if tag in {'p', 'article', 'main'}:
self.in_content = True
if tag in {'h1', 'h2', 'h3'}:
self.content.append('\n')
def handle_data(self, data):
if self.in_content and data.strip():
self.content.append(data.strip())
def get_content(self):
return '\n\n'.join(self.content)
parser = ArticleExtractor()
parser.feed(sys.stdin.read())
print(parser.get_content())
" > temp_article.txt
;;
esac
# 清理文件名
FILENAME=$(echo "$TITLE" | tr '/' '-' | tr ':' '-' | tr '?' '' | tr '"' '' | tr '<>' '' | tr '|' '-' | cut -c 1-80 | sed 's/ *$//' | sed 's/^ *//')
FILENAME="${FILENAME}.txt"
# 移动到最终文件名
mv temp_article.txt "$FILENAME"
# 显示结果
echo "✓ 已提取文章:$TITLE"
echo "✓ 已保存至:$FILENAME"
echo ""
echo "预览(前 10 行):"
head -n 10 "$FILENAME"
1. 工具未安装
2. 付费墙或需要登录
3. 无效 URL
4. 未提取到内容
5. 标题包含特殊字符
/, :, ?, ", <, >, |- 或直接移除1. 针对大多数文章使用 reader
2. 在以下情况下使用 trafilatura:
3. 备选方法的局限性:
4. 检查提取质量:
简单提取:
# 用户:"提取 https://example.com/article"
reader "https://example.com/article" > temp.txt
TITLE=$(head -n 1 temp.txt | sed 's/^# //')
FILENAME="$(echo "$TITLE" | tr '/' '-').txt"
mv temp.txt "$FILENAME"
echo "✓ 已保存至:$FILENAME"
带有错误处理:
if ! reader "$URL" > temp.txt 2>/dev/null; then
if command -v trafilatura &> /dev/null; then
trafilatura --URL "$URL" --output-format txt > temp.txt
else
echo "错误:无法提取文章。请安装 reader 或 trafilatura。"
exit 1
fi
fi
向用户显示:
如有需要,询问: