8
n8n 中文网amn8n.com

将最近3天RSS源保存到Google Sheets的阅读器

高级

这是一个Other, IT Ops领域的自动化工作流,包含 23 个节点。主要使用 Set, Code, Wait, Markdown, RssFeedRead 等节点。 将最近3天RSS源保存到Google Sheets的阅读器

前置要求
  • Google Sheets API 凭证
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "meta": {
    "instanceId": "27b4a6a8d6961d7c3fc76935cbb847cc60b06fde7d9f2077fe73e1a9efa7a010"
  },
  "nodes": [
    {
      "id": "cfb41f0c-9dd3-46c8-aae1-2f6caaf1a1e3",
      "name": "定时触发器",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        -2440,
        220
      ],
      "parameters": {
        "rule": {
          "interval": [
            {}
          ]
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "07d78dcb-1a2d-45f4-b595-734e301c25ee",
      "name": "获取简报",
      "type": "n8n-nodes-base.set",
      "onError": "continueRegularOutput",
      "position": [
        -1440,
        220
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "f3530e8d-0694-4b73-bd9f-f4ce763c059b",
              "name": "id",
              "type": "string",
              "value": "={{ $json.link }}"
            },
            {
              "id": "e829100d-7301-4ee3-9e8e-782b476b98c3",
              "name": "title",
              "type": "string",
              "value": "={{ $json.title }}"
            },
            {
              "id": "637000e7-a294-4656-b3b2-36d3ff42ce8d",
              "name": "output",
              "type": "string",
              "value": "={{ $json.content }}"
            },
            {
              "id": "6626b922-4ac9-4a04-a55d-d02cebeee7f2",
              "name": "pubDate",
              "type": "string",
              "value": "={{ $json.pubDate }}"
            },
            {
              "id": "134b45eb-3048-40c8-9c1c-2b9d45959de4",
              "name": "tags",
              "type": "string",
              "value": "={{ $json.categories }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "7c7d0915-dfc2-4041-ae0f-6af6e008eab1",
      "name": "代码",
      "type": "n8n-nodes-base.code",
      "onError": "continueRegularOutput",
      "position": [
        -1180,
        220
      ],
      "parameters": {
        "jsCode": "const now = new Date();\nconst setdays = 3; // Edit the Days, if you need the News from more the 3 Days\nconst cutoffDate = new Date();\ncutoffDate.setDate(now.getDate() - setdays); \nreturn $input.all().filter(item => {\n    const pubDate = new Date(Date.parse(item.json.pubDate));\n    return !isNaN(pubDate.getTime()) && pubDate >= cutoffDate;\n});"
      },
      "typeVersion": 2
    },
    {
      "id": "d5ac9f75-60a4-4bde-b4c1-ccb2f940d5f8",
      "name": "Markdown",
      "type": "n8n-nodes-base.markdown",
      "onError": "continueRegularOutput",
      "position": [
        -900,
        460
      ],
      "parameters": {
        "html": "={{ $json.output }}",
        "options": {},
        "destinationKey": "output"
      },
      "typeVersion": 1
    },
    {
      "id": "e7ec484d-f667-4123-acb4-60e0cbdb62e0",
      "name": "遍历项目",
      "type": "n8n-nodes-base.splitInBatches",
      "onError": "continueRegularOutput",
      "position": [
        -920,
        220
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 3
    },
    {
      "id": "0065ce76-9840-48b2-860c-c4a2928479a8",
      "name": "等待",
      "type": "n8n-nodes-base.wait",
      "onError": "continueRegularOutput",
      "position": [
        -900,
        880
      ],
      "webhookId": "85941a4b-202f-4368-a331-dbfdf018326b",
      "parameters": {
        "amount": 2.5
      },
      "typeVersion": 1.1,
      "alwaysOutputData": true
    },
    {
      "id": "06edc173-5352-4810-bc9f-cc24cc263ee6",
      "name": "循环遍历项目1",
      "type": "n8n-nodes-base.splitInBatches",
      "onError": "continueRegularOutput",
      "position": [
        -1820,
        220
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 3
    },
    {
      "id": "069bc633-9273-471c-a2c7-1559c62eb370",
      "name": "RSS",
      "type": "n8n-nodes-base.rssFeedRead",
      "onError": "continueRegularOutput",
      "position": [
        -1800,
        480
      ],
      "parameters": {
        "url": "={{ $json.Links }}",
        "options": {}
      },
      "typeVersion": 1.1
    },
    {
      "id": "6575e570-0a1b-49db-b0b1-938dd2732dd6",
      "name": "代码1",
      "type": "n8n-nodes-base.code",
      "onError": "continueRegularOutput",
      "position": [
        -100,
        220
      ],
      "parameters": {
        "jsCode": "const now = new Date();\nconst setdays = 3; // Edit the Days, if you need the News from more the 3 Days\nconst cutoffDate = new Date();\ncutoffDate.setDate(now.getDate() - setdays);  \n\nconst oldRows = $input.all().filter(item => {\n    const pubDate = new Date(item.json.pubDate);\n    return pubDate < cutoffDate;\n});\noldRows.sort((a, b) => b.json.row_number - a.json.row_number);\nreturn oldRows.map(item => ({ json: { rowNumber: item.json.row_number } }));\n"
      },
      "typeVersion": 2
    },
    {
      "id": "d68a46d3-58ea-4cc7-a1f7-ef014f600908",
      "name": "遍历项目2",
      "type": "n8n-nodes-base.splitInBatches",
      "onError": "continueRegularOutput",
      "position": [
        240,
        220
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 3,
      "alwaysOutputData": true
    },
    {
      "id": "ed132a67-67fa-42e1-9f73-0b645005a332",
      "name": "等待1",
      "type": "n8n-nodes-base.wait",
      "onError": "continueRegularOutput",
      "position": [
        260,
        680
      ],
      "webhookId": "69b1b17d-85d1-4681-8887-85e2644f4752",
      "parameters": {
        "amount": 25
      },
      "typeVersion": 1.1
    },
    {
      "id": "61d7aae8-2d3f-4425-9e4b-247aa5fd2cea",
      "name": "等待 2",
      "type": "n8n-nodes-base.wait",
      "onError": "continueRegularOutput",
      "position": [
        -660,
        220
      ],
      "webhookId": "69b1b17d-85d1-4681-8887-85e2644f4752",
      "parameters": {
        "unit": "minutes",
        "amount": 1
      },
      "executeOnce": true,
      "typeVersion": 1.1
    },
    {
      "id": "8cf26c46-a2e1-4ea0-8c8b-a948bb77e286",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2480,
        -120
      ],
      "parameters": {
        "width": 500,
        "height": 1340,
        "content": "## 定时器每24小时启动更新,并从Google Sheets文件读取链接(RSS链接)"
      },
      "typeVersion": 1
    },
    {
      "id": "b7eb361f-7ff1-436c-82d1-0c348e652a26",
      "name": "便签1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1960,
        -120
      ],
      "parameters": {
        "width": 440,
        "height": 1340,
        "content": "## 每个单独链接被扫描和检索"
      },
      "typeVersion": 1
    },
    {
      "id": "2037525d-afbe-4aba-9dd4-b00df8560706",
      "name": "便签 2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1500,
        -120
      ],
      "parameters": {
        "width": 480,
        "height": 1340,
        "content": "## 超过3天的所有内容被移除"
      },
      "typeVersion": 1
    },
    {
      "id": "0e7eff1a-10e0-4f7a-8e2d-4046248878bc",
      "name": "便签 3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1000,
        -120
      ],
      "parameters": {
        "width": 300,
        "height": 1340,
        "content": "## 每个条目以等待时间单独保存到Google Sheets文件(RSS源),等待时间是必要的,否则Google Sheets会收到过多请求并阻止访问!"
      },
      "typeVersion": 1
    },
    {
      "id": "8cd16f67-ebc8-4009-81a1-54da9aac47ef",
      "name": "便签 4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -680,
        -120
      ],
      "parameters": {
        "width": 420,
        "height": 1340,
        "content": "## 读取Google Sheets文件中保存的条目(RSS源)"
      },
      "typeVersion": 1
    },
    {
      "id": "ed9d8dc7-e8e7-4441-a43c-8c86a7e0be52",
      "name": "便签 5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -240,
        -120
      ],
      "parameters": {
        "width": 360,
        "height": 1340,
        "content": "## 移除所有少于3天的内容,因为我们只想删除较旧的条目!"
      },
      "typeVersion": 1
    },
    {
      "id": "fbb3391c-bac7-4e2c-8231-a8f48d70c21c",
      "name": "便签6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        140,
        -120
      ],
      "parameters": {
        "width": 360,
        "height": 1340,
        "content": "## 此处删除所有超过3天的条目,再次使用定时器防止Google API阻止!(RSS源)"
      },
      "typeVersion": 1
    },
    {
      "id": "3a800065-971b-4f37-bc3f-9c8ade78217e",
      "name": "删除新闻",
      "type": "n8n-nodes-base.googleSheets",
      "onError": "continueRegularOutput",
      "position": [
        260,
        460
      ],
      "parameters": {
        "operation": "delete",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1iFwBIRDfUEZFACoL4bXfeT4Ot2i5vWfEew69fYRfz0A/edit#gid=0",
          "cachedResultName": "Tabellenblatt1"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1iFwBIRDfUEZFACoL4bXfeT4Ot2i5vWfEew69fYRfz0A",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1iFwBIRDfUEZFACoL4bXfeT4Ot2i5vWfEew69fYRfz0A/edit?usp=drivesdk",
          "cachedResultName": "RSS-Feeds"
        },
        "startIndex": "={{ $json.rowNumber }}"
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "pmmVpF25NsJia8r0",
          "name": "Google Sheets account"
        }
      },
      "typeVersion": 4.5,
      "alwaysOutputData": false
    },
    {
      "id": "31d13f16-c9ad-4b08-b129-bb5ed51d4657",
      "name": "读取新闻",
      "type": "n8n-nodes-base.googleSheets",
      "onError": "continueErrorOutput",
      "position": [
        -440,
        220
      ],
      "parameters": {
        "options": {
          "outputFormatting": {
            "values": {
              "date": "FORMATTED_STRING",
              "general": "FORMATTED_VALUE"
            }
          },
          "dataLocationOnSheet": {
            "values": {
              "rangeDefinition": "detectAutomatically"
            }
          }
        },
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1iFwBIRDfUEZFACoL4bXfeT4Ot2i5vWfEew69fYRfz0A/edit#gid=0",
          "cachedResultName": "Tabellenblatt1"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1iFwBIRDfUEZFACoL4bXfeT4Ot2i5vWfEew69fYRfz0A",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1iFwBIRDfUEZFACoL4bXfeT4Ot2i5vWfEew69fYRfz0A/edit?usp=drivesdk",
          "cachedResultName": "RSS-Feeds"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "pmmVpF25NsJia8r0",
          "name": "Google Sheets account"
        }
      },
      "typeVersion": 4.5,
      "alwaysOutputData": false
    },
    {
      "id": "13bb0584-96bb-4184-9698-509b34f6be25",
      "name": "保存新闻",
      "type": "n8n-nodes-base.googleSheets",
      "onError": "continueRegularOutput",
      "position": [
        -900,
        680
      ],
      "parameters": {
        "columns": {
          "value": {
            "id": "={{ $json.id }}",
            "title": "={{ $json.title }}",
            "output": "={{ $json.output }}",
            "pubDate": "={{ $json.pubDate }}",
            "Category": "={{ $json.tags }}"
          },
          "schema": [
            {
              "id": "id",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "id",
              "defaultMatch": true,
              "canBeUsedToMatch": true
            },
            {
              "id": "title",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "title",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "output",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "output",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "pubDate",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "pubDate",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Category",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Category",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "id"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {
          "useAppend": true
        },
        "operation": "appendOrUpdate",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1iFwBIRDfUEZFACoL4bXfeT4Ot2i5vWfEew69fYRfz0A/edit#gid=0",
          "cachedResultName": "Tabellenblatt1"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1iFwBIRDfUEZFACoL4bXfeT4Ot2i5vWfEew69fYRfz0A",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1iFwBIRDfUEZFACoL4bXfeT4Ot2i5vWfEew69fYRfz0A/edit?usp=drivesdk",
          "cachedResultName": "RSS-Feeds"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "pmmVpF25NsJia8r0",
          "name": "Google Sheets account"
        }
      },
      "typeVersion": 4.5,
      "alwaysOutputData": true
    },
    {
      "id": "d3224fc9-d7a7-47c1-9db2-8615499e1124",
      "name": "读取链接",
      "type": "n8n-nodes-base.googleSheets",
      "onError": "continueErrorOutput",
      "position": [
        -2200,
        220
      ],
      "parameters": {
        "options": {
          "outputFormatting": {
            "values": {
              "date": "FORMATTED_STRING",
              "general": "FORMATTED_VALUE"
            }
          },
          "dataLocationOnSheet": {
            "values": {
              "rangeDefinition": "detectAutomatically"
            }
          }
        },
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/12p3M0Umh_Xlpm4Y04IpOFqE8YOJcCd97wPJNv80X8u4/edit#gid=0",
          "cachedResultName": "Tabellenblatt1"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "12p3M0Umh_Xlpm4Y04IpOFqE8YOJcCd97wPJNv80X8u4",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/12p3M0Umh_Xlpm4Y04IpOFqE8YOJcCd97wPJNv80X8u4/edit?usp=drivesdk",
          "cachedResultName": "RSS-Links"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "pmmVpF25NsJia8r0",
          "name": "Google Sheets account"
        }
      },
      "typeVersion": 4.5
    }
  ],
  "pinData": {},
  "connections": {
    "RSS": {
      "main": [
        [
          {
            "node": "Loop Over Items1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Code": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Code1": {
      "main": [
        [
          {
            "node": "Loop Over Items2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait1": {
      "main": [
        [
          {
            "node": "Loop Over Items2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait2": {
      "main": [
        [
          {
            "node": "Read News",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Markdown": {
      "main": [
        [
          {
            "node": "Save News",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Read News": {
      "main": [
        [
          {
            "node": "Code1",
            "type": "main",
            "index": 0
          }
        ],
        []
      ]
    },
    "Save News": {
      "main": [
        [
          {
            "node": "Wait",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Read Links": {
      "main": [
        [
          {
            "node": "Loop Over Items1",
            "type": "main",
            "index": 0
          }
        ],
        []
      ]
    },
    "Delete News": {
      "main": [
        [
          {
            "node": "Wait1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Edit Fields": {
      "main": [
        [
          {
            "node": "Code",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop Over Items": {
      "main": [
        [
          {
            "node": "Wait2",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Markdown",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop Over Items1": {
      "main": [
        [
          {
            "node": "Edit Fields",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "RSS",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop Over Items2": {
      "main": [
        [],
        [
          {
            "node": "Delete News",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Schedule Trigger": {
      "main": [
        [
          {
            "node": "Read Links",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。

这个工作流适合什么场景?

高级 - 其他, IT 运维

需要付费吗?

本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。

工作流信息
难度等级
高级
节点数量23
分类2
节点类型9
难度说明

适合高级用户,包含 16+ 个节点的复杂工作流

作者
Holger

Holger

@capa

Hobby programmer since 2001, interested in automation and AI

外部链接
在 n8n.io 查看

分享此工作流