知识库 · AI 智能体
让博客内容像流水线一样更新:n8n 批量自动发布WordPress全攻略
教你用 n8n 打造内容生产流水线:通过聊天输入话题,自动抓取 YouTube/TikTok 字幕、Twitter 内容,经 LLM 智能改写为微信风格稿件,再转 Markdown 并批量自动发布到 WordPress,实现个人知识网站高效更新。
让博客内容像流水线一样更新:n8n 批量自动发布WordPress全攻略
2025年6月25日修改
今天,小宝就带你用 n8n 打造一条“内容生产流水线”,轻松实现个人播客网站 批量、自动发布!
核心思路
通过聊天框输入内容话题
拆分链接:Split Out 节点提取话题
内容抓取:
YouTube/Tiktok ➜ 获取视频信息 + 字幕
Twitter/Instagram ➜ 抓取推文
循环处理:Loop Over Items + HTTP Request 同步处理多条内容
智能改写:调用 LLM(Gemini/DeepSeek)生成微信公众号风格稿件
Markdown 转 HTML:排版一次到位
WordPress 发布:OAuth2 认证上传+绑定特色图
详细步骤 & 节点配置
1 Chat Message
选择 on chat message 节点作为触发器,代表收到聊天消息则执行工作流(“Make Chat Publicly Available”默认关闭,下期将讲解开启后可应用的场景)
2 Split Out:提取用户输入
3 Http Request:批量获取相关视频字幕
请求体里配置 json 格式文本内容:
代码块
{
"dateFilter": "week",
"downloadSubtitles": false,
"hasCC": false,
"hasLocation": false,
"hasSubtitles": false,
"is360": false,
"is3D": false,
"is4K": false,
"isBought": false,
"isHD": false,
"isHDR": false,
"isLive": false,
"isVR180": false,
"lengthFilter": "plus20",
"maxResultStreams": 0,
"maxResults": 10,
"maxResultsShorts": 10,
"preferAutoGeneratedSubtitles": true,
"saveSubsToKVS": true,
"searchQueries": [
{{ $json.chatInput.toJsonString() }}
],
"sortingOrder": "views",
"subtitlesLanguage": "any",
"videoType": "video"
} 4 Loop+Http request:批量获取视频字幕
通过循环节点设置每次执行 item数量为 1,http 节点则获取该批次视频字幕,循环直至所有视频字幕提取完成
5 Code:数据清理
通过 code 节点提取所有 item 的字幕,组合成一个完整的字幕文本返回
代码块
// Access all input items (each one is a video)
const items = $input.all();
// For each video item, join the captions from data[]
const result = items.map(item => {
const data = item.json.data;
// Safely join text only if data is an array
const fullCaption = Array.isArray(data)
? data.map(d => d.text).join(' ')
: '';
return {
json: {
full_caption: fullCaption
}
};
});
return result;
6 AI Agent:内容转写
通过Agent 节点,将上个节点的字幕文本转写为适合博客网站发布的内容与格式,提示词参考如下:
代码块
YouTube transcript: {{ $json.full_caption }}
---
### TASK:
Using the above content, write a **WordPress-friendly blog post** specifically for **non-technical visitors**.
Please follow these requirements:
- **Audience**: Beginner/intermediate AI learners with no technical background
- **Tone**: Clear, friendly, educational, and slightly conversational
- **Structure**:
- Catchy title
- Engaging introduction (use story, scenario, or question to pull in)
- Key takeaways or main idea (from transcript and tweet)
- Real-life marketing use case(s) with GenAI (but NO code, no technical setup)
- Add a section for "What you can try next" to inspire action
- Call-to-action (subscribe, comment, or listen to full episode)
- **DO NOT include** technical jargon, implementation steps, or anything related to code or API.
### OUTPUT FORMAT:
Output ONLY a valid JSON object with no markdown formatting, **no ```json``` wrapping**, and no explanation. Just pure JSON like this:
{
"title": "Your Title",
"content": "Full content in plain string with \\n and escaped quotes"
}
7 Code: 格式化输出
为更稳定的适配下游节点,我们设置 code 节点将 title 和 content 格式化输出,代码参考如下:
代码块
const raw = $json.output;
let parsed;
try {
parsed = JSON.parse(raw);
} catch (e) {
const err = e instanceof Error ? e : new Error(String(e));
throw new Error("❌ Failed to parse output JSON:\n\n" + raw + "\n\nReason: " + err.message);
}
return {
json: {
title: parsed.title,
content: parsed.content
}
};
8 Markdown :➜ HTML
对 content 部分处理为更便于 WordPress 渲染的 HTML 格式
9 Http Request:WordPress 发稿
身份认证:选择 ‘generic credential type’进行认证,认证类型OAuth2 api,自行前往 WordPress 开发网站获取 相关 client id 和 secret(如果是 WordPress upgrade 用户,则直接使用 n8n 自行预定义的 WordPress 进行认证即可)
成品测试
在 对话框 输入 “n8n”
3 分钟后,WordPress 出现 10 篇排版完美的新文章
一站式内容工厂,真·管饱!
写在最后
以上就是 “博客网站批量自动发布” 的完整实现。从内容抓取、生成到分发,全程无人值守,把你的创作时间还给更有价值的领域。
如果你也想为博客、视频号、Newsletter 做同款自动化,或者有更广泛的渠道内容抓取需求,请留言或者私信,我会根据你的需求提供定制化解决方案,帮你高效实现内容聚合与分发!
我是芋头小宝,关注我,持续带你探索GenAI的成长宇宙。
如果你觉得这篇文章对你有帮助,别忘了点赞+收藏+转发哦~
相关文章推荐: