自动抓取X推文并发布到Telegram副本2
中级
这是一个自动化工作流,包含 14 个节点。主要使用 Code, Wait, Telegram, HttpRequest, GoogleSheets 等节点。 自动抓取X图片帖子并发布到Telegram,使用Google表格存储
前置要求
- •Telegram Bot Token
- •可能需要目标 API 的认证凭证
- •Google Sheets API 凭证
使用的节点 (14)
分类
-
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
"id": "ptwolWvQwd2VnU5e",
"meta": {
"instanceId": "237139412ba2bdccb5393d058ace6ee50c6bb809e4f130ea2f9b24f70a336b94"
},
"name": "自动抓取 X 推文并发布到 Telegram 副本 2",
"tags": [],
"nodes": [
{
"id": "260d511b-12b8-4dfb-93d9-6d0317c49dea",
"name": "移除重复项",
"type": "n8n-nodes-base.removeDuplicates",
"position": [
512,
-112
],
"parameters": {
"options": {
"historySize": 10000
},
"operation": "removeItemsSeenInPreviousExecutions",
"dedupeValue": "={{ $json.tweet_id }}"
},
"typeVersion": 2
},
{
"id": "863dc17e-446c-4118-9171-0db7402b967f",
"name": "遍历项目",
"type": "n8n-nodes-base.splitInBatches",
"position": [
-16,
224
],
"parameters": {
"options": {}
},
"typeVersion": 3
},
{
"id": "a13ca579-f044-4900-94f2-675d012ffa64",
"name": "触发器:开始在 X 上抓取",
"type": "n8n-nodes-base.manualTrigger",
"position": [
-512,
-112
],
"parameters": {},
"typeVersion": 1
},
{
"id": "1939f7d2-4ebd-459c-aaaa-8c4f5fdd0e94",
"name": "Twitter API",
"type": "n8n-nodes-base.httpRequest",
"position": [
-272,
-112
],
"parameters": {
"url": "https://api.twitterapi.io/twitter/user/last_tweets",
"options": {},
"sendQuery": true,
"authentication": "genericCredentialType",
"genericAuthType": "httpHeaderAuth",
"queryParameters": {
"parameters": [
{
"name": "userID",
"value": "1361142028667662338"
},
{
"name": "userName",
"value": "@Inku_Fr"
}
]
}
},
"credentials": {
"httpHeaderAuth": {
"id": "L7K4reMunvy4mC3C",
"name": "X scrapping utilisateur"
}
},
"typeVersion": 4.2
},
{
"id": "9a988b26-1746-4175-b0ff-92c06f391d99",
"name": "仅筛选包含文本和图片的推文",
"type": "n8n-nodes-base.code",
"position": [
256,
-112
],
"parameters": {
"jsCode": "// Filter only tweets that have text and an image\nreturn items\n .map(item => {\n return {\n json: {\n author_name: item.json.author_name,\n author_username: item.json.author_username,\n tweet_text: item.json.tweet_text,\n tweet_url: item.json.tweet_url,\n tweet_id: item.json.tweet_id,\n created_at: item.json.created_at,\n image_url: item.json.first_image_url // retrieve the image link\n }\n };\n })\n .filter(item => item.json.tweet_text && item.json.image_url); // only keeps tweets with text AND images\n"
},
"typeVersion": 2
},
{
"id": "93da9f3b-fea4-4d56-a900-298891ccd28d",
"name": "将抓取数据保存到 Google Sheets",
"type": "n8n-nodes-base.googleSheets",
"position": [
-512,
224
],
"parameters": {
"columns": {
"value": {
"URL": "={{ $json.tweet_url }}",
"Date": "={{ $json.created_at }}",
"Image": "={{ $json.image_url }}",
"Contenu": "={{ $json.tweet_text }}",
"ID Tweet": "={{ $json.tweet_id }}",
"Nom du compte": "={{ $json.author_name }}",
"Nom d'utilisateur": "={{ $json.author_username }}"
},
"schema": [
{
"id": "ID Tweet",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "ID Tweet",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "URL",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "URL",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "Contenu",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "Contenu",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "Date",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "Date",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "Image",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "Image",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "Nom d'utilisateur",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "Nom d'utilisateur",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "Nom du compte",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "Nom du compte",
"defaultMatch": false,
"canBeUsedToMatch": true
}
],
"mappingMode": "defineBelow",
"matchingColumns": [],
"attemptToConvertTypes": false,
"convertFieldsToString": false
},
"options": {},
"operation": "append",
"sheetName": {
"__rl": true,
"mode": "list",
"value": "gid=0",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/1MSy_TwbRjl_IprnzZp9yX_W8pLeVxPd1c_gNnJgtykY/edit#gid=0",
"cachedResultName": "Feuille 1"
},
"documentId": {
"__rl": true,
"mode": "list",
"value": "1xZbBYTPYAW-625aRFwfxNzkTA-nbVY7Mv_EX3ubk1uQ",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/1xZbBYTPYAW-625aRFwfxNzkTA-nbVY7Mv_EX3ubk1uQ/edit?usp=drivesdk",
"cachedResultName": "INSTANT ANIME"
}
},
"credentials": {
"googleSheetsOAuth2Api": {
"id": "fvaXnOXV63MxY546",
"name": "Google Sheets account 4"
}
},
"typeVersion": 4.6
},
{
"id": "4fc30aa0-ef16-4865-80f4-1b8e7d924d4f",
"name": "格式化并移除抓取数据中的链接",
"type": "n8n-nodes-base.code",
"position": [
-272,
224
],
"parameters": {
"jsCode": "// Filter and clean tweets\nreturn $input.all()\n .map(item => {\n let text = item.json.Contenu;\n\n // Removes links\n text = text.replace(/https?:\\/\\/\\S+/g, '').trim();\n\n return {\n json: {\n author_name: item.json[\"Nom du compte\"],\n author_username: item.json[\"Nom d'utilisateur\"],\n tweet_text: text,\n tweet_url: item.json.URL,\n tweet_id: item.json[\"ID Tweet\"],\n created_at: item.json.Date,\n first_image_url: item.json.Image,\n }\n };\n })\n // Only keep tweets that have text and an image\n .filter(item => item.json.tweet_text && item.json.first_image_url);\n"
},
"typeVersion": 2
},
{
"id": "f3495493-6a6a-48b8-979d-35e246583fc3",
"name": "每条推文等待 3 分钟",
"type": "n8n-nodes-base.wait",
"position": [
512,
240
],
"webhookId": "1eeb5acf-2934-4d56-b9a7-aeeb203dd465",
"parameters": {
"unit": "minutes",
"amount": 3
},
"typeVersion": 1.1
},
{
"id": "83ca9695-a6d7-4ed5-86c5-8455ecbf984e",
"name": "在频道中发送照片和文本",
"type": "n8n-nodes-base.telegram",
"position": [
256,
240
],
"webhookId": "d009379b-bf0d-4468-bea8-0a1ae64e8c99",
"parameters": {
"file": "={{ $json.first_image_url }}",
"chatId": "=@instantanimee",
"operation": "sendPhoto",
"additionalFields": {
"caption": "={{ $json.tweet_text }}"
}
},
"credentials": {
"telegramApi": {
"id": "kbRZDVqu7tIpKwc7",
"name": "Telegram account"
}
},
"typeVersion": 1.2
},
{
"id": "6d359557-113a-4b5a-ae02-df43ecf98a67",
"name": "便签",
"type": "n8n-nodes-base.stickyNote",
"position": [
-368,
-272
],
"parameters": {
"color": 6,
"width": 256,
"height": 352,
"content": "## 输入您要抓取的用户账户 ID 和用户名"
},
"typeVersion": 1
},
{
"id": "f36be26a-4ae5-4e8a-b52b-d1b78726328a",
"name": "便签1",
"type": "n8n-nodes-base.stickyNote",
"position": [
-64,
-272
],
"parameters": {
"color": 6,
"width": 784,
"height": 352,
"content": "## 它将格式化数据。同时筛选推文,仅保留包含文本和至少一张图片的推文"
},
"typeVersion": 1
},
{
"id": "7fa0a416-8c2e-48dd-9aab-144d9f2afd82",
"name": "便签2",
"type": "n8n-nodes-base.stickyNote",
"position": [
-592,
144
],
"parameters": {
"color": 6,
"width": 1312,
"height": 320,
"content": "## 在您的 Telegram 频道发布推文,每条推文间隔 3 分钟"
},
"typeVersion": 1
},
{
"id": "09e7411e-dca4-43ad-8cb9-4f0e95f5448f",
"name": "便签4",
"type": "n8n-nodes-base.stickyNote",
"position": [
-1488,
-480
],
"parameters": {
"width": 624,
"height": 1216,
"content": ""
},
"typeVersion": 1
},
{
"id": "5641d972-fc52-4c85-8a30-5ecbf6308852",
"name": "便签3",
"type": "n8n-nodes-base.stickyNote",
"position": [
-816,
-480
],
"parameters": {
"color": 7,
"width": 1792,
"height": 1056,
"content": "## 使用此工作流自动化从 X(Twitter)抓取推文并发布到 Telegram 频道的过程"
},
"typeVersion": 1
}
],
"active": false,
"pinData": {},
"settings": {
"executionOrder": "v1"
},
"versionId": "e1819680-5476-42e8-8fc1-56098c8e04b6",
"connections": {
"Twitter API": {
"main": [
[
{
"node": "Filter only tweets that have text and an image",
"type": "main",
"index": 0
}
]
]
},
"Loop Over Items": {
"main": [
[],
[
{
"node": "Send a photo and text in your channel",
"type": "main",
"index": 0
}
]
]
},
"Remove Duplicates": {
"main": [
[
{
"node": "Save the scraping Data in a google sheet",
"type": "main",
"index": 0
}
]
]
},
"Wait 3 minutes per post": {
"main": [
[
{
"node": "Loop Over Items",
"type": "main",
"index": 0
}
]
]
},
"Trigger : Start scraping on X": {
"main": [
[
{
"node": "Twitter API",
"type": "main",
"index": 0
}
]
]
},
"Send a photo and text in your channel": {
"main": [
[
{
"node": "Wait 3 minutes per post",
"type": "main",
"index": 0
}
]
]
},
"Save the scraping Data in a google sheet": {
"main": [
[
{
"node": "Format and remove links from the scraping data",
"type": "main",
"index": 0
}
]
]
},
"Filter only tweets that have text and an image": {
"main": [
[
{
"node": "Remove Duplicates",
"type": "main",
"index": 0
}
]
]
},
"Format and remove links from the scraping data": {
"main": [
[
{
"node": "Loop Over Items",
"type": "main",
"index": 0
}
]
]
}
}
}常见问题
如何使用这个工作流?
复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。
这个工作流适合什么场景?
中级
需要付费吗?
本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。
相关工作流推荐
使用APIFY和ChatGPT抓取并总结Google Maps企业信息
使用 APIFY + GPT-4O 抓取并总结 Google Maps 企业信息到表格
Wait
Google Sheets
Apify
+5
16 节点Jaures NYA
潜在客户开发
API架构提取器
API架构提取器
If
Set
Code
+22
88 节点Polina Medvedieva
工程
LinkedIn和X病毒内容自动引擎
使用AI生成和发布自动创建LinkedIn和X的病毒内容
If
Set
Wait
+26
156 节点Diptamoy Barman
内容创作
域名外联:自动化潜在客户提取和定向触达
域名外联:自动化潜在客户提取和定向触达
If
Code
Wait
+11
31 节点Badr
销售
在可视化参考库中探索n8n节点
在可视化参考库中探索n8n节点
If
Ftp
Set
+93
113 节点I versus AI
其他
从Google地图列表提取商业邮箱用于潜在客户生成
从Google地图列表提取商业邮箱用于潜在客户生成
Code
Wait
Limit
+8
20 节点Jose Castillo
潜在客户开发