8
n8n 中文网amn8n.com

YouTube - 获取视频评论

高级

这是一个Market Research领域的自动化工作流,包含 16 个节点。主要使用 If, SplitOut, HttpRequest, GoogleSheets, ManualTrigger 等节点。 提取YouTube视频评论并存储至Google Sheets

前置要求
  • 可能需要目标 API 的认证凭证
  • Google Sheets API 凭证
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "id": "XVI3nC7HVl7JU6C5",
  "meta": {
    "instanceId": "ed6d846a2fce1f660ede2e7da800724cca01dc3d0685524a3c917881b7cfcfe9",
    "templateCredsSetupCompleted": true
  },
  "name": "Youtube - 获取视频评论",
  "tags": [
    {
      "id": "CEVEeZJa4qgPvdpK",
      "name": "youtube",
      "createdAt": "2025-05-27T02:29:43.874Z",
      "updatedAt": "2025-05-27T02:29:43.874Z"
    }
  ],
  "nodes": [
    {
      "id": "7677397f-8b7b-4428-84c9-b25a0e8f6fe9",
      "name": "分离",
      "type": "n8n-nodes-base.splitOut",
      "position": [
        -620,
        340
      ],
      "parameters": {
        "options": {},
        "fieldToSplitOut": "body.items"
      },
      "typeVersion": 1,
      "alwaysOutputData": true
    },
    {
      "id": "ecc0c645-7297-4279-be21-7f623d84dd6d",
      "name": "If - 检查成功响应",
      "type": "n8n-nodes-base.if",
      "position": [
        -840,
        500
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "bce76f94-5904-4fdb-b172-adc1134855f9",
              "operator": {
                "type": "number",
                "operation": "equals"
              },
              "leftValue": "={{ $json.statusCode }}",
              "rightValue": 200
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "f0d9fee0-dded-486e-90a6-0992c14c4731",
      "name": "Google Sheets - 更新状态",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        340,
        480
      ],
      "parameters": {
        "columns": {
          "value": {
            "status": "finish",
            "row_number": "={{ $('Google Sheets - Get Video URLs').item.json.row_number }}",
            "last_fetched_time": "={{ $now.toISO().toString().slice(0, 19).replace('T', ' ') }}"
          },
          "schema": [
            {
              "id": "status",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "status",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "video_url",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "video_url",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "last_fetched_time",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "last_fetched_time",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "row_number",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": true,
              "required": false,
              "displayName": "row_number",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "row_number"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "update",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": 426418282,
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/18-3CmJPbC73MycmNiSWotdsyGBAAzqESf33vktwnYmM/edit#gid=426418282",
          "cachedResultName": "Video URLs"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1F5yEhjBWu3fnwgHGLsPLD9_tWRqUnxu4p0DEvUTae1Y",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1F5yEhjBWu3fnwgHGLsPLD9_tWRqUnxu4p0DEvUTae1Y/edit?usp=drivesdk",
          "cachedResultName": "YouTube - Crawl Video Comments"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "pe6UD1A6MWIk2X91",
          "name": "Google Sheets - toan.ngo"
        }
      },
      "executeOnce": true,
      "typeVersion": 4.5
    },
    {
      "id": "47690f02-9a22-4bc7-8ee7-112b1c9d9b0b",
      "name": "遍历项目",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        -1440,
        480
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 3
    },
    {
      "id": "ab7d7339-f848-4ea3-9370-4d9c6a36515a",
      "name": "If - 检查视频网址非空",
      "type": "n8n-nodes-base.if",
      "position": [
        -1800,
        500
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "loose"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "8bf50878-b1b3-45dd-9639-98238fcef579",
              "operator": {
                "type": "string",
                "operation": "notEmpty",
                "singleValue": true
              },
              "leftValue": "={{ $json.video_url }}",
              "rightValue": ""
            }
          ]
        },
        "looseTypeValidation": true
      },
      "typeVersion": 2.2
    },
    {
      "id": "3b3e13e1-1ac9-4e86-b1b5-b67547a4fc80",
      "name": "HTTP Request - 获取评论",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -1220,
        500
      ],
      "parameters": {
        "url": "https://www.googleapis.com/youtube/v3/commentThreads",
        "options": {
          "response": {
            "response": {
              "fullResponse": true,
              "responseFormat": "json"
            }
          },
          "pagination": {
            "pagination": {
              "parameters": {
                "parameters": [
                  {
                    "name": "pageToken",
                    "value": "={{ $response.body.nextPageToken }}"
                  }
                ]
              },
              "completeExpression": "={{ !$response.body.nextPageToken}}",
              "paginationCompleteWhen": "other"
            }
          }
        },
        "sendQuery": true,
        "authentication": "predefinedCredentialType",
        "queryParameters": {
          "parameters": [
            {
              "name": "part",
              "value": "snippet"
            },
            {
              "name": "videoId",
              "value": "={{ $json.video_url.match(/(?:v=|\\/)([0-9A-Za-z_-]{11})/)[1] || ''}}"
            },
            {
              "name": "limit",
              "value": "100"
            }
          ]
        },
        "nodeCredentialType": "youTubeOAuth2Api"
      },
      "credentials": {
        "youTubeOAuth2Api": {
          "id": "KhD0GLQGWl8MtqCs",
          "name": "YouTube - toan.ngo"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "b1c18c3c-8eb7-42a8-b2dd-1d98199a20f3",
      "name": "If - 检查评论是否存在",
      "type": "n8n-nodes-base.if",
      "position": [
        -420,
        340
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "e4d47098-097d-4fd7-9703-638858f9565a",
              "operator": {
                "type": "string",
                "operation": "exists",
                "singleValue": true
              },
              "leftValue": "={{ $json.snippet.videoId }}",
              "rightValue": ""
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "993d9d75-9db9-4ef6-98aa-7598ca390bd3",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -3080,
        -140
      ],
      "parameters": {
        "width": 700,
        "height": 1420,
        "content": "## [Agent Circle 的 N8N 工作流] YouTube 视频评论爬虫 - 立即试用!"
      },
      "typeVersion": 1
    },
    {
      "id": "95fa0de2-7dbd-4ce3-be2b-1f3aa0a25f9b",
      "name": "Google Sheets - 获取视频网址",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        -1960,
        500
      ],
      "parameters": {
        "options": {},
        "filtersUI": {
          "values": [
            {
              "lookupValue": "ready",
              "lookupColumn": "status"
            }
          ]
        },
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": 426418282,
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1F5yEhjBWu3fnwgHGLsPLD9_tWRqUnxu4p0DEvUTae1Y/edit#gid=426418282",
          "cachedResultName": "Video URLs"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1F5yEhjBWu3fnwgHGLsPLD9_tWRqUnxu4p0DEvUTae1Y",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1F5yEhjBWu3fnwgHGLsPLD9_tWRqUnxu4p0DEvUTae1Y/edit?usp=drivesdk",
          "cachedResultName": "YouTube - Crawl Video Comments"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "pe6UD1A6MWIk2X91",
          "name": "Google Sheets - toan.ngo"
        }
      },
      "typeVersion": 4.5
    },
    {
      "id": "4aab513c-f3f7-4014-92e7-95a584f8d35b",
      "name": "Google Sheets - 插入/更新评论",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        140,
        340
      ],
      "parameters": {
        "columns": {
          "value": {
            "likes": "={{ $json.snippet.topLevelComment.snippet.likeCount }}",
            "reply": "={{ $json.snippet.totalReplyCount }}",
            "comment": "={{ $json.snippet.topLevelComment.snippet.textOriginal }}",
            "video_url": "=https://www.youtube.com/watch?v={{ $json.snippet.videoId }}",
            "comment_id": "={{ $json.snippet.topLevelComment.id }}",
            "author_name": "={{ $json.snippet.topLevelComment.snippet.authorDisplayName }}",
            "published_at": "={{ $json.snippet.topLevelComment.snippet.publishedAt.toString().slice(0, 19).replace('T', ' ') }}"
          },
          "schema": [
            {
              "id": "video_url",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "video_url",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "comment_id",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "comment_id",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "comment",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "comment",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "author_name",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "author_name",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "likes",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "likes",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "reply",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "reply",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "published_at",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "published_at",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "comment_id"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "appendOrUpdate",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/18-3CmJPbC73MycmNiSWotdsyGBAAzqESf33vktwnYmM/edit#gid=0",
          "cachedResultName": "Results "
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1F5yEhjBWu3fnwgHGLsPLD9_tWRqUnxu4p0DEvUTae1Y",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1F5yEhjBWu3fnwgHGLsPLD9_tWRqUnxu4p0DEvUTae1Y/edit?usp=drivesdk",
          "cachedResultName": "YouTube - Crawl Video Comments"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "pe6UD1A6MWIk2X91",
          "name": "Google Sheets - toan.ngo"
        }
      },
      "typeVersion": 4.5
    },
    {
      "id": "b22f440c-caac-4812-8ec4-02ee4aaeb85a",
      "name": "测试工作流",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        -2140,
        500
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "893156f1-ef54-42dd-9aa6-5f3c8fc4d6ce",
      "name": "便签1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2180,
        120
      ],
      "parameters": {
        "color": 7,
        "width": 580,
        "height": 720,
        "content": "## 1. 从关联的 Google Sheet 读取视频网址"
      },
      "typeVersion": 1
    },
    {
      "id": "efc99293-f219-40e4-9980-ca96ed1ff156",
      "name": "便签2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1500,
        120
      ],
      "parameters": {
        "color": 7,
        "width": 480,
        "height": 720,
        "content": "## 2. 通过 YouTube API 获取评论"
      },
      "typeVersion": 1
    },
    {
      "id": "0254b9d7-ad4a-42b9-b1f2-d412184b67d4",
      "name": "便签3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -920,
        100
      ],
      "parameters": {
        "color": 7,
        "width": 860,
        "height": 720,
        "content": "## 3. 验证响应并拆分评论"
      },
      "typeVersion": 1
    },
    {
      "id": "d66bf88b-b703-4d41-b328-363e9fd2aa7e",
      "name": "便签4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        40,
        100
      ],
      "parameters": {
        "color": 7,
        "width": 480,
        "height": 720,
        "content": "## 4. 在 Google Sheets 中保存评论并更新网址状态"
      },
      "typeVersion": 1
    },
    {
      "id": "29abcb72-024c-43bb-a726-ba513f12f0fb",
      "name": "Google Sheets - 更新状态 - 错误",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        140,
        580
      ],
      "parameters": {
        "columns": {
          "value": {
            "status": "error",
            "row_number": "={{ $('Google Sheets - Get Video URLs').item.json.row_number }}",
            "last_fetched_time": "={{ $now.toISO().toString().slice(0, 19).replace('T', ' ') }}"
          },
          "schema": [
            {
              "id": "status",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "status",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "video_url",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "video_url",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "last_fetched_time",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "last_fetched_time",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "row_number",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": true,
              "required": false,
              "displayName": "row_number",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "row_number"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "update",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": 426418282,
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1F5yEhjBWu3fnwgHGLsPLD9_tWRqUnxu4p0DEvUTae1Y/edit#gid=426418282",
          "cachedResultName": "Video URLs"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1F5yEhjBWu3fnwgHGLsPLD9_tWRqUnxu4p0DEvUTae1Y",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1F5yEhjBWu3fnwgHGLsPLD9_tWRqUnxu4p0DEvUTae1Y/edit?usp=drivesdk",
          "cachedResultName": "YouTube - Get Video Comments"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "pe6UD1A6MWIk2X91",
          "name": "Google Sheets - toan.ngo"
        }
      },
      "typeVersion": 4.6
    }
  ],
  "active": false,
  "pinData": {
    "Test Workflow": [
      {
        "json": {}
      }
    ]
  },
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "386de5d5-8061-49e2-868f-0e04f358a9d1",
  "connections": {
    "Split Out": {
      "main": [
        [
          {
            "node": "If - Check Comment Exists",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Test Workflow": {
      "main": [
        [
          {
            "node": "Google Sheets - Get Video URLs",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop Over Items": {
      "main": [
        [],
        [
          {
            "node": "HTTP Request - Get Comments",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If - Check Comment Exists": {
      "main": [
        [
          {
            "node": "Google Sheets - Insert/Update Comment",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Google Sheets - Update Status - Error",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HTTP Request - Get Comments": {
      "main": [
        [
          {
            "node": "If - Check Success Response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If - Check Success Response": {
      "main": [
        [
          {
            "node": "Split Out",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Google Sheets - Update Status - Error",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Sheets - Update Status": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Sheets - Get Video URLs": {
      "main": [
        [
          {
            "node": "If - Check Video Url is Not Empty",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If - Check Video Url is Not Empty": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Sheets - Insert/Update Comment": {
      "main": [
        [
          {
            "node": "Google Sheets - Update Status",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Sheets - Update Status - Error": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

高级 - 市场调研

需要付费吗?

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

工作流信息
难度等级
高级
节点数量16
分类1
节点类型7
难度说明

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

作者
Agent Circle

Agent Circle

@agentcircle

Agent Circle - A growing marketplace of AI agents, workflows, and toolkits — built to help teams automate smarter and scale faster

外部链接
在 n8n.io 查看

分享此工作流