Communitygithub.com

baronguyen001/ai-automation-skills

使用標準函式庫(無需 BeautifulSoup/lxml)將 HTML 轉換為純文字:移除 script/style、將區塊標籤轉為換行、並壓縮空白。適用於當使用者需要從 HTML 頁面/郵件中取得可讀文字、在將抓取的 HTML 餵給 LLM 前清除標記,或從網頁內容建立文字索引時。

ai-automation-skills 是什麼?

這項技能提供一個輕量級的 HTML 轉純文字工具,完全依賴 Python 標準函式庫中的 `html.parser.HTMLParser`,無需安裝 `beautifulsoup4` 或 `lxml` 等第三方套件。主要功能是移除 `<script>` 與 `<style>` 內容、將區塊元素轉換為換行符號、並壓縮連續空白與空行,輸出適合閱讀或用於 LLM 提示(減少 token 數)的文字。支援任何能執行 Python 的環境,包含 Claude Code、Cursor、Codex 等 AI 代理平台。使用方式非常簡單:複製內附的 `assets/htmltext.py` 檔案後,呼叫 `html_to_text()` 函式即可。這項技能是從作者的爬蟲與摘要流程中提煉而來,特別適合用於清理網頁內容、電子報或 RSS 文章,以便後續進行摘要或建立搜尋索引。

相容平台~Claude Code~Codex CLI~Cursor✓Gemini CLI
npx skills add https://github.com/baronguyen001/ai-automation-skills/tree/HEAD/skills/html-to-text

在你喜歡的 AI 中提問

開啟一個已預先載入此 Agent Skill 的新對話。

說明文件

HTML 轉純文字

當您有 HTML(例如:抓取的網頁、電子報內容、RSS 條目的內容)且希望在不添加 beautifulsoup4 或 lxml 的情況下獲得乾淨、可讀的純文字時,請使用此技能。一個小型的 HTMLParser 子類別會移除 <script>/<style>,將區塊元素轉換為換行符號,並壓縮空白,這正是您在將內容送給 LLM(減少 token)或放入搜尋索引前所需的格式。

何時使用

  • 使用者說:「從這個 HTML 中取出文字」、「清理這個抓取的頁面」、「在摘要前移除標籤」、「將此電子郵件 HTML 轉為文字」。
  • HTML 即將被餵給模型或摘要,而標記只是雜訊。

何時不要使用

  • 您需要保留結構(表格、連結作為 Markdown)——請使用真正的 HTML-to-Markdown 轉換器。
  • 頁面是由 JavaScript 渲染的——請先用無頭瀏覽器擷取,然後再轉換。

具體範例

使用者輸入:

將這篇文章的 HTML 轉為純文字,以便我用更少的 token 來摘要。

輸出:

# 將 assets/htmltext.py 複製到您的專案中,然後:
from htmltext import html_to_text

text = html_to_text(article_html)
summary = call_llm(f"摘要:\n{text}")

<script> 和 <style> 區塊會被完全移除,區塊標籤變成換行符號,連續的空格和空行會被壓縮,因此輸出讀起來就像散文。

套用的模式

  1. 繼承 html.parser.HTMLParser,設定 convert_charrefs=True 以自動解碼實體。
  2. 追蹤 script/style/head 的跳過深度,確保它們的文字永遠不會洩漏到輸出中。
  3. 在區塊標籤前後插入換行,然後壓縮行內空白及多個空行。
  4. 保持純粹(字串輸入、字串輸出),以便輕鬆進行單元測試。

參考:assets/htmltext.py。

來源

萃取自作者的爬蟲與摘要流程。v1.0.0。 另請參閱:[[rss-feed-reader]]、[[gemini-cost-tracker]]、[[pipeline-orchestrator]]。

→ 使用 Trawlkit 建立完整的可執行機器人。

Individual skills in this repo

This repo contains 9 individual skills — each has its own dedicated page.

baronguyen001/ai-automation-skills

Schedule any script to run on a recurring schedule on Windows (Task Scheduler) or Linux (cron) - register, list, and remove jobs from one command, with logging to a file and a guard against overlapping runs. Use for schedule a script, run nightly, set up a cron job, windows task scheduler, or run on a timer.

baronguyen001/ai-automation-skills

Turn a run's list of result dicts into a schema'd CSV and a Markdown table from one column spec - declare columns once, emit both, with stable ordering and safe escaping, stdlib only, no pandas. Use when the user asks to write results to CSV, export a report, make a markdown summary table, or save a run's output as a spreadsheet.

baronguyen001/ai-automation-skills

Persist records between scheduled runs as append-only JSON Lines (one object per line) with streaming reads and optional key-based dedup, stdlib only. Use when the user wants to log run results to JSONL, append events to a file, dedup records by id across runs, or keep a simple durable history without a database.

baronguyen001/ai-automation-skills

Extract text and simple table-like rows from a PDF for downstream AI without OCR binaries. Use when the user asks to read a PDF, turn a PDF into text, pull simple tables from statements/reports, or feed PDF content into an LLM pipeline.

baronguyen001/ai-automation-skills

Rotate a pool of HTTP/SOCKS proxies with round-robin selection, failure tracking, and a cooldown that benches dead proxies before retrying. BYO proxy list via env - none are shipped. Use for rotate proxies, spread requests across proxies, avoid IP bans, retry through a different proxy, or proxy health check.

baronguyen001/ai-automation-skills

Parse an RSS 2.0 or Atom feed into normalized item dicts (title, link, id, published, summary) with the standard library only - no feedparser. Use when the user asks to read an RSS/Atom feed, poll a blog/news feed, extract feed entries, or watch a site that publishes a feed.

baronguyen001/ai-automation-skills

Upload and download run artifacts from S3-compatible storage with BYO bucket and credentials from env. Use when the user asks to store scraper output, archive reports, publish artifacts to object storage, fetch a prior run file, or use MinIO/R2/Spaces/S3 without hardcoding credentials.

baronguyen001/ai-automation-skills

Draft a short-form TikTok/Reels/Shorts or long-form video script from a topic and creator persona file - hook variants, beat-structured body, CTA, b-roll cues, caption overlays, and [STORY]/[NUMBER] slots so the model never fabricates personal facts. Use for write a video script, tiktok script, youtube script, or /shortform-script.

baronguyen001/ai-automation-skills

Give scheduled scripts memory between runs with one SQLite file - a seen-set for dedup, a key/value cursor to resume where you left off, and order-preserving new-item filtering. Use for dedup across runs, don't re-alert the same item, remember the last id, resume a scraper, or persist state between cron runs.

相關技能