1
0
Files
Skill/skills/lyxy-reader-html/SKILL.md
lanyuanxiaoyao 6b4fcf2647 创建 lyxy-reader-html skill
- 新增 skill: lyxy-reader-html,用于解析 HTML 文件和 URL 网页内容
- 支持 URL 下载(pyppeteer → selenium → httpx → urllib 优先级回退)
- 支持 HTML 解析(trafilatura → domscribe → MarkItDown → html2text 优先级回退)
- 支持查询功能:全文提取、字数统计、行数统计、标题提取、章节提取、正则搜索
- 新增 spec: html-document-parsing
- 归档 change: create-lyxy-reader-html-skill
2026-03-08 02:02:03 +08:00

76 lines
3.1 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
---
name: lyxy-reader-html
description: 解析 HTML 文件和 URL 网页内容的 skill将 HTML 转换为 Markdown 格式支持全文提取、标题提取、章节提取、正则搜索、字数统计、行数统计。URL 模式下自动下载网页内容,支持 JS 渲染。使用时请阅读 scripts/README.md 获取详细用法。
compatibility: Requires Python 3.6+. 推荐通过 lyxy-runner-python skill 使用 uv 自动管理依赖。
---
# HTML 网页解析 Skill
将 HTML 文件或 URL 网页内容解析为 Markdown 格式,支持多种查询模式。
## Purpose
**统一入口**:使用 `scripts/parser.py` 作为统一的命令行入口自动识别输入类型URL 或 HTML 文件)并执行解析。
**依赖选项**:此 skill 必须优先使用 lyxy-runner-python skill 执行,不可用时降级到直接 Python 执行。
## When to Use
任何需要读取或解析 HTML 文件、URL 网页内容的任务都应使用此 skill。
### 典型场景
- **网页内容提取**:将 URL 或本地 HTML 文件转换为可读的 Markdown 文本
- **文档元数据**:获取文档的字数、行数等信息
- **标题分析**:提取文档的标题结构
- **章节提取**:提取特定章节的内容
- **内容搜索**:在文档中搜索关键词或模式
### 触发词
- 中文:"读取/解析/打开 html/htm 网页/URL"
- 英文:"read/parse/extract html/htm web page url"
- 文件扩展名:`.html``.htm`
- URL 模式:`http://``https://`
## Quick Reference
| 参数 | 说明 |
|------|------|
| (无参数) | 输出完整 Markdown 内容 |
| `-c` | 字数统计 |
| `-l` | 行数统计 |
| `-t` | 提取所有标题 |
| `-tc <name>` | 提取指定标题的章节内容 |
| `-s <pattern>` | 正则表达式搜索 |
| `-n <num>` | 与 `-s` 配合,指定上下文行数 |
## Workflow
1. **检查依赖**:优先使用 lyxy-runner-python否则降级到直接 Python 执行
2. **识别输入**:自动判断是 URL 还是本地 HTML 文件
3. **下载内容**URL 模式下按 pyppeteer → selenium → httpx → urllib 优先级下载
4. **清理 HTML**:移除 script/style/link/svg 等标签和 URL 属性
5. **执行解析**:按 trafilatura → domscribe → MarkItDown → html2text 优先级解析
6. **输出结果**:返回 Markdown 格式内容或统计信息
### 基本语法
```bash
# 使用 lyxy-runner-python推荐
uv run --with trafilatura --with domscribe --with markitdown --with html2text --with httpx --with pyppeteer --with selenium --with beautifulsoup4 scripts/parser.py https://example.com
# 降级到直接执行
python3 scripts/parser.py https://example.com
```
## References
详细文档请参阅 `references/` 目录:
| 文件 | 内容 |
|------|------|
| `references/examples.md` | URL 和 HTML 文件的完整提取、字数统计、标题提取、章节提取、搜索等示例 |
| `references/parsers.md` | 解析器说明、依赖安装、各解析器输出特点、能力说明 |
| `references/error-handling.md` | 限制说明、最佳实践、依赖执行策略 |
> **详细用法**:请阅读 `scripts/README.md` 获取完整的命令行参数和依赖安装指南。