非常棒👏!這個「新聞爬蟲 → 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 | 顯示或儲存摘要 | ✅ 免費 |
Manual Trigger
↓
HTTP Request (抓取新聞 RSS / HTML)
↓
Function (擷取第一篇文章內容)
↓
HTTP Request (Hugging Face Summarize)
↓
Function (格式化輸出)
在 n8n 中建立一個新 workflow,命名為:D23-demo
新增節點:
設定如下:
欄位 | 設定 |
---|---|
Method | GET |
URL | https://api.taiwantoday.tw/en/rss.php?unit=2,6,10,15,18 |
Response Format | XML |
✅ 說明:BBC 中文網的 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
}
}];
✅ 說明:
取出 RSS 第一篇新聞的標題與連結。
設定如下:
欄位 | 設定 |
---|---|
Method | POST |
URL | https://api-inference.huggingface.co/models/facebook/bart-large-cnn |
Headers | Authorization: Bearer hf_你的token 、Content-Type: application/json |
Body Parameters | {"inputs": "={{$json.article}}", "parameters": {"min_length": 60, "max_length": 200}} |
✅ 說明:將新聞文章丟給 Hugging Face 模型進行摘要。
return [{
json: {
title: $json.title || "新聞標題",
summary: $json[0]?.summary_text || $json.generated_text || "未成功生成摘要"
}
}];
展示成果:
[
{
"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.\"}]"
}
]