8
n8n 中文网amn8n.com

网页变更检测与Google套件哈希追踪告警

中级

这是一个Other, IT Ops领域的自动化工作流,包含 14 个节点。主要使用 Set, Html, Gmail, Crypto, Markdown 等节点。 网页变更检测与Google套件哈希追踪告警

前置要求
  • Google 账号和 Gmail API 凭证
  • Google Drive API 凭证
  • 可能需要目标 API 的认证凭证
  • Google Sheets API 凭证
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "meta": {
    "instanceId": "408f9fb9940c3cb18ffdef0e0150fe342d6e655c3a9fac21f0f644e8bedabcd9",
    "templateCredsSetupCompleted": true
  },
  "nodes": [
    {
      "id": "1083afcb-1257-45a3-b331-d93fb8769548",
      "name": "计划触发器",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        -840,
        0
      ],
      "parameters": {
        "rule": {
          "interval": [
            {}
          ]
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "c3ec0759-a3d1-4866-978a-bfe4f49ee81d",
      "name": "获取内容哈希值",
      "type": "n8n-nodes-base.crypto",
      "position": [
        380,
        0
      ],
      "parameters": {
        "value": "={{ $json.data }}",
        "dataPropertyName": "hash"
      },
      "typeVersion": 1
    },
    {
      "id": "4ad92ad3-6f99-43a5-9a61-374adb3b28f7",
      "name": "变更通知",
      "type": "n8n-nodes-base.gmail",
      "position": [
        1220,
        0
      ],
      "webhookId": "cc4cbee1-ad57-48fb-810a-b21880357ab0",
      "parameters": {
        "sendTo": "jim@example.com",
        "message": "=site: {{ $('Variables').first().json.url }}\ndate: {{ $now.toISO() }}\nhash: {{ $json.hash }}\ncontents: {{ $json.gdrive }}",
        "options": {},
        "subject": "=Change detected for {{ $('Variables').first().json.url }}",
        "emailType": "text"
      },
      "credentials": {
        "gmailOAuth2": {
          "id": "Sf5Gfl9NiFTNXFWb",
          "name": "Gmail account"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "9385242a-86b1-4624-ada9-949851b68054",
      "name": "Markdown",
      "type": "n8n-nodes-base.markdown",
      "position": [
        200,
        0
      ],
      "parameters": {
        "html": "={{ $json.content.trim() }}",
        "options": {}
      },
      "typeVersion": 1
    },
    {
      "id": "663b6ba2-cbf9-44ea-a062-f88ccb0640c1",
      "name": "变量",
      "type": "n8n-nodes-base.set",
      "position": [
        -460,
        0
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "fa706ed3-7425-4f0e-9590-d9478b4e6692",
              "name": "url",
              "type": "string",
              "value": "https://x.com/en/tos"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "2ef69fff-4d7a-439a-b317-ea5fa3ce7869",
      "name": "仅新哈希值",
      "type": "n8n-nodes-base.removeDuplicates",
      "position": [
        560,
        0
      ],
      "parameters": {
        "options": {
          "historySize": 1
        },
        "operation": "removeItemsSeenInPreviousExecutions",
        "dedupeValue": "={{ $json.hash }}"
      },
      "typeVersion": 2
    },
    {
      "id": "93e13d80-a26f-408f-be4e-b582ab9fd9bd",
      "name": "日志记录",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        1040,
        0
      ],
      "parameters": {
        "columns": {
          "value": {
            "hash": "={{ $('Get Hash of Contents').first().json.hash }}",
            "gdrive": "=https://drive.google.com/file/d/{{ $json.id }}/view?usp=sharing",
            "website": "={{ $('Variables').first().json.url }}",
            "date of change": "={{ $now.toISO() }}"
          },
          "schema": [
            {
              "id": "website",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "website",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "hash",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "hash",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "date of change",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "date of change",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "gdrive",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "gdrive",
              "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/1K13OBMicH-ebhvJRYo4sHiOuHd1KIX2jiFxBLWy2UOk/edit#gid=0",
          "cachedResultName": "Sheet1"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1K13OBMicH-ebhvJRYo4sHiOuHd1KIX2jiFxBLWy2UOk",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1K13OBMicH-ebhvJRYo4sHiOuHd1KIX2jiFxBLWy2UOk/edit?usp=drivesdk",
          "cachedResultName": "86. Webpage Changes Tracker"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "XHvC7jIRR8A2TlUl",
          "name": "Google Sheets account"
        }
      },
      "typeVersion": 4.5
    },
    {
      "id": "dea15963-61de-4371-b716-7683e0e703a9",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -540,
        -160
      ],
      "parameters": {
        "color": 7,
        "width": 620,
        "height": 380,
        "content": "## 1. 获取网页内容"
      },
      "typeVersion": 1
    },
    {
      "id": "bcb1c0b1-fc77-4417-a9c0-6299ce8ca33e",
      "name": "便签1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        100,
        -160
      ],
      "parameters": {
        "color": 7,
        "width": 640,
        "height": 400,
        "content": "## 2. 使用哈希检测变更"
      },
      "typeVersion": 1
    },
    {
      "id": "eda51de6-80a2-42b1-83ba-66c551911c45",
      "name": "获取网页",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -280,
        0
      ],
      "parameters": {
        "url": "={{ $json.url }}",
        "options": {},
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "User-Agent",
              "value": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.36"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "8aa998f1-1558-4b54-a95a-7be9360a819a",
      "name": "提取内容",
      "type": "n8n-nodes-base.html",
      "position": [
        -100,
        0
      ],
      "parameters": {
        "options": {},
        "operation": "extractHtmlContent",
        "extractionValues": {
          "values": [
            {
              "key": "content",
              "cssSelector": ".ct07",
              "returnValue": "html"
            }
          ]
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "ecb60054-563c-4c0b-949c-abdcd3896f6b",
      "name": "便签2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        760,
        -160
      ],
      "parameters": {
        "color": 7,
        "width": 660,
        "height": 400,
        "content": "## 3. 发生变更时通知"
      },
      "typeVersion": 1
    },
    {
      "id": "30774606-5e63-4d73-9894-ba14d5b1fc46",
      "name": "拍摄快照",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        860,
        0
      ],
      "parameters": {
        "name": "={{\n$('Variables').item.json.url\n  .extractDomain()\n  .replace('.','_')\n  + $json.hash\n  + '.md'\n}}",
        "content": "={{ $json.data }}",
        "driveId": {
          "__rl": true,
          "mode": "list",
          "value": "My Drive"
        },
        "options": {},
        "folderId": {
          "__rl": true,
          "mode": "list",
          "value": "1BbP5HRnjNkCvcDRFFg1bm0sNYBGZM6AU",
          "cachedResultUrl": "https://drive.google.com/drive/folders/1BbP5HRnjNkCvcDRFFg1bm0sNYBGZM6AU",
          "cachedResultName": "86. Monitor Webpage Changes"
        },
        "operation": "createFromText"
      },
      "credentials": {
        "googleDriveOAuth2Api": {
          "id": "yOwz41gMQclOadgu",
          "name": "Google Drive account"
        }
      },
      "typeVersion": 3
    },
    {
      "id": "9ae563ea-49a3-4dcc-9190-8746650018aa",
      "name": "便签3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1040,
        -760
      ],
      "parameters": {
        "width": 440,
        "height": 980,
        "content": "## 试试看"
      },
      "typeVersion": 1
    }
  ],
  "pinData": {},
  "connections": {
    "Markdown": {
      "main": [
        [
          {
            "node": "Get Hash of Contents",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Variables": {
      "main": [
        [
          {
            "node": "Fetch Webpage",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Log Record": {
      "main": [
        [
          {
            "node": "Notify of Change",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch Webpage": {
      "main": [
        [
          {
            "node": "Extract Contents",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Only New Hashes": {
      "main": [
        [
          {
            "node": "Take a Snapshot",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Take a Snapshot": {
      "main": [
        [
          {
            "node": "Log Record",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract Contents": {
      "main": [
        [
          {
            "node": "Markdown",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Schedule Trigger": {
      "main": [
        [
          {
            "node": "Variables",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Hash of Contents": {
      "main": [
        [
          {
            "node": "Only New Hashes",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

中级 - 其他, IT 运维

需要付费吗?

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

工作流信息
难度等级
中级
节点数量14
分类2
节点类型11
难度说明

适合有一定经验的用户,包含 6-15 个节点的中等复杂度工作流

作者
Jimleuk

Jimleuk

@jimleuk

Freelance consultant based in the UK specialising in AI-powered automations. I work with select clients tackling their most challenging projects. For business enquiries, send me an email at hello@jimle.uk LinkedIn: https://www.linkedin.com/in/jimleuk/ X/Twitter: https://x.com/jimle_uk

外部链接
在 n8n.io 查看

分享此工作流