iT邦幫忙

2025 iThome 鐵人賽

DAY 20
0
DevOps

Mac 環境 n8n 30 天學習計畫系列 第 23

Day 23-AI 新聞摘要自動化展示📑

  • 分享至 

  • xImage
  •  

非常棒👏!這個「新聞爬蟲 → AI 摘要」的任務,是一個完整的 AI 自動化展示專案,可以同時示範「資料擷取(Web Scraping)」、「AI 自動處理(Summarization)」與「流程自動化(Workflow)」三大技能。
我會幫你設計成在 Mac + n8n 環境中能免費執行的版本,不用額外伺服器或付費 API。


🎯 專案目標

自動從新聞網站抓取最新一篇文章 → AI 自動摘要 → 輸出結果(例如 Notion、Google Sheet 或 Console)


🧩 主要工具

工具 功能 免費可行性
n8n 自動化流程平台 ✅ 免費本地執行
新聞 RSS / API 取得即時新聞(例如 BBC 中文網、中央社) ✅ 免費
Hugging Face API (facebook/bart-large-cnn) AI 摘要模型 ✅ 免費 Token 可用
Console / Notion API 顯示或儲存摘要 ✅ 免費

🏗️ 流程架構 (Workflow Overview)

Manual Trigger
   ↓
HTTP Request (抓取新聞 RSS / HTML)
   ↓
Function (擷取第一篇文章內容)
   ↓
HTTP Request (Hugging Face Summarize)
   ↓
Function (格式化輸出)

https://ithelp.ithome.com.tw/upload/images/20251008/201691449BYAfNzuqf.png

🧱 逐步操作說明

Step 1|建立 Workflow

在 n8n 中建立一個新 workflow,命名為:D23-demo


Step 2|Manual Trigger

新增節點:

  • Node 名稱:Manual Trigger
  • 作用:手動啟動流程

Step 3|HTTP Request RSS(抓取新聞)

設定如下:

欄位 設定
Method GET
URL https://api.taiwantoday.tw/en/rss.php?unit=2,6,10,15,18
Response Format XML

https://ithelp.ithome.com.tw/upload/images/20251008/20169144ZuTdYtEPcs.png
說明:BBC 中文網的 RSS 會回傳最新新聞清單。


Step 4|Function(解析 RSS)

新增 Function 節點,輸入以下程式碼:

const xml = $input.first().json.content; // 取得上一步的 XML 文字

// 用正則表達式取出資料(簡易法,適合結構固定)
return [{
  json: {
    title:$input.first().json.title,
    content:$input.first().json.contentSnippet,
    link:$input.first().json.link
  }
}];

https://ithelp.ithome.com.tw/upload/images/20251008/20169144hAOgTQUgdV.png

說明
取出 RSS 第一篇新聞的標題與連結。


Step 5|HTTP Request(Hugging Face Summarize)

設定如下:

欄位 設定
Method POST
URL https://api-inference.huggingface.co/models/facebook/bart-large-cnn
Headers Authorization: Bearer hf_你的tokenContent-Type: application/json
Body Parameters {"inputs": "={{$json.article}}", "parameters": {"min_length": 60, "max_length": 200}}

https://ithelp.ithome.com.tw/upload/images/20251008/20169144IcqM1fIv0N.png

說明:將新聞文章丟給 Hugging Face 模型進行摘要。


Step 6|Function(整理輸出)

return [{
  json: {
    title: $json.title || "新聞標題",
    summary: $json[0]?.summary_text || $json.generated_text || "未成功生成摘要"
  }
}];

https://ithelp.ithome.com.tw/upload/images/20251008/20169144ZKGWgKtKSG.png


展示成果:

[
  {
    "title": "President Lai Ching-te attends indigenous satellite send-off",
    "summary": "[{\"summary_text\":\"President Lai Ching-te welcomed the Formosat-8A satellite’s departure for the U.S. for launch. Lai attended a ceremony at the Taiwan Space Agency (TASA) headquartered in Hsinchu on Oct. 7 and noted that as Taiwan's first indigenous satellite, it was an important milestone in the development of Taiwan's space technology.\"}]"
  }
]

https://ithelp.ithome.com.tw/upload/images/20251008/201691442C9ktwXWKl.png


上一篇
Day 22:AI + Email 自動回覆草稿HuggingFace API(免費模型)
下一篇
Day 24:AI + 自動化的潛力(與傳統自動化比較)
系列文
Mac 環境 n8n 30 天學習計畫24
圖片
  熱門推薦
圖片
{{ item.channelVendor }} | {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言