8
n8n 中文网amn8n.com

通过Bright Data API的Twitter个人资料抓取器,输出到Google Sheets

中级

这是一个Market Research领域的自动化工作流,包含 15 个节点。主要使用 If, Wait, FormTrigger, HttpRequest, GoogleSheets 等节点。 使用Bright Data API抓取Twitter个人资料并导出到Google Sheets

前置要求
  • 可能需要目标 API 的认证凭证
  • Google Sheets API 凭证
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "id": "aklI9zFDCmfAo9hA",
  "meta": {
    "instanceId": "bc8ca75c203589705ae2e446cad7181d6f2a7cc1766f958ef9f34810e53b8cb2"
  },
  "name": "通过 Bright Data API 的 Twitter 个人资料抓取器,输出到 Google Sheets",
  "tags": [],
  "nodes": [
    {
      "id": "ac0410b2-4a26-4b4b-a4fe-b676754337df",
      "name": "📥 用户输入触发器",
      "type": "n8n-nodes-base.formTrigger",
      "position": [
        -1312,
        16
      ],
      "webhookId": "279eebd7-d383-47d3-a912-b3a60afbd003",
      "parameters": {
        "options": {},
        "formTitle": "Twitter profile url",
        "formFields": {
          "values": [
            {
              "fieldLabel": "Twitter Profile url"
            },
            {
              "fieldType": "date",
              "fieldLabel": "start date"
            },
            {
              "fieldType": "date",
              "fieldLabel": "end date"
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "4541f9d3-7c19-44e1-935b-56fce3e52317",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1376,
        -48
      ],
      "parameters": {
        "width": 224,
        "height": 208,
        "content": "→ 通过表单中的 Twitter URL 和日期范围启动流程"
      },
      "typeVersion": 1
    },
    {
      "id": "4c03a5bd-3121-4c13-ade9-33c8eaed1043",
      "name": "🚀 触发 Twitter 抓取",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -1040,
        16
      ],
      "parameters": {
        "url": "https://api.brightdata.com/datasets/v3/trigger",
        "method": "POST",
        "options": {},
        "jsonBody": "{\n  \"input\": [\n    {\n      \"url\": \"{{ $json['Twitter Profile url'] }}\",\n      \"start_date\": \"{{ $json['start date'] }}\",\n      \"end_date\": \"{{ $json['end date'] }}\"\n    }\n  ],\n  \"custom_output_fields\": [\n    \"id\",\n    \"user_posted\",\n    \"name\",\n    \"description\",\n    \"date_posted\",\n    \"photos\",\n    \"url\",\n    \"quoted_post\",\n    \"tagged_users\",\n    \"replies\",\n    \"reposts\",\n    \"likes\",\n    \"views\",\n    \"external_url\",\n    \"hashtags\",\n    \"followers\",\n    \"posts_count\",\n    \"profile_image_link\",\n    \"following\",\n    \"is_verified\",\n    \"quotes\",\n    \"parent_post_details\",\n    \"external_image_urls\",\n    \"videos\",\n    \"external_video_urls\",\n    \"user_id\",\n    \"timestamp\"\n  ]\n}",
        "sendBody": true,
        "sendQuery": true,
        "sendHeaders": true,
        "specifyBody": "json",
        "queryParameters": {
          "parameters": [
            {
              "name": "dataset_id",
              "value": "gd_lwxkxvnf1cynvib9co"
            },
            {
              "name": "include_errors",
              "value": "true"
            },
            {
              "name": "type",
              "value": "discover_new"
            },
            {
              "name": "discover_by",
              "value": "profile_url"
            }
          ]
        },
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "Bearer BRIGHT_DATA_API_KEY"
            }
          ]
        }
      },
      "typeVersion": 4.2,
      "alwaysOutputData": true
    },
    {
      "id": "9fa82381-8c38-4704-8cb0-e8aa4e469d5a",
      "name": "便签1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1120,
        -48
      ],
      "parameters": {
        "color": 2,
        "height": 208,
        "content": "→ 使用用户输入向 BrightData 发送抓取请求"
      },
      "typeVersion": 1
    },
    {
      "id": "4f544be2-c578-4de3-8cdf-db3f9e443530",
      "name": "🔄 监控抓取进度",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -784,
        16
      ],
      "parameters": {
        "url": "=https://api.brightdata.com/datasets/v3/progress/{{ $json.snapshot_id }}",
        "options": {},
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "Bearer BRIGHT_DATA_API_KEY"
            }
          ]
        }
      },
      "typeVersion": 4.2,
      "alwaysOutputData": true
    },
    {
      "id": "701e0ed1-3658-48cf-aebf-cefac22a94e3",
      "name": "便签2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -848,
        -48
      ],
      "parameters": {
        "color": 3,
        "width": 224,
        "height": 208,
        "content": "→ 检查抓取是否仍在运行或已就绪"
      },
      "typeVersion": 1
    },
    {
      "id": "88cfbb92-c12f-45ba-bdab-c48476d33676",
      "name": "⏱️ 重新检查前的延迟",
      "type": "n8n-nodes-base.wait",
      "position": [
        -544,
        16
      ],
      "webhookId": "10b45556-5e91-4387-abd0-f9078b220286",
      "parameters": {
        "unit": "minutes",
        "amount": 1
      },
      "typeVersion": 1.1
    },
    {
      "id": "c976c82b-6e1d-4f51-8224-e314bfc703c7",
      "name": "便签3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -608,
        -48
      ],
      "parameters": {
        "color": 4,
        "width": 224,
        "height": 208,
        "content": "→ 等待 1 分钟后再检查状态"
      },
      "typeVersion": 1
    },
    {
      "id": "d107f520-3621-4d2d-9887-07a860461b95",
      "name": "✅ 抓取是否就绪?",
      "type": "n8n-nodes-base.if",
      "position": [
        -304,
        16
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "or",
          "conditions": [
            {
              "id": "35ed620d-b5d5-4e97-bcc5-52b283d85616",
              "operator": {
                "name": "filter.operator.equals",
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $json.status }}",
              "rightValue": "ready"
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "8ee62b09-4073-424d-b051-381134548eb9",
      "name": "便签说明4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -352,
        -48
      ],
      "parameters": {
        "color": 5,
        "width": 224,
        "height": 208,
        "content": "→ 如果就绪,则获取数据;如果未就绪,则重复检查循环"
      },
      "typeVersion": 1
    },
    {
      "id": "e53c14eb-e7cb-443a-bfeb-1a6842d839a6",
      "name": "📦 获取 Twitter 数据",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -48,
        0
      ],
      "parameters": {
        "url": "=https://api.brightdata.com/datasets/v3/snapshot/{{ $json.snapshot_id }}",
        "options": {},
        "sendQuery": true,
        "sendHeaders": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "format",
              "value": "json"
            }
          ]
        },
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "Bearer BRIGHT_DATA_API_KEY"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "9b713be8-53f8-42e9-8c70-ae158ffee142",
      "name": "便签说明5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -112,
        -48
      ],
      "parameters": {
        "color": 6,
        "width": 224,
        "height": 208,
        "content": "→ 使用快照 ID 下载抓取的推文数据"
      },
      "typeVersion": 1
    },
    {
      "id": "1182993d-0cf0-4a65-99d0-7cd65bfe56c2",
      "name": "📊 将 Twitter 数据存储到 Google Sheet",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        176,
        0
      ],
      "parameters": {
        "columns": {
          "value": {
            "id": "={{ $json.id }}",
            "name": "={{ $json.name }}",
            "likes": "={{ $json.likes }}",
            "views": "={{ $json.views }}",
            "photos": "={{ $json.photos }}",
            "quotes": "={{ $json.quotes }}",
            "videos": "={{ $json.videos }}",
            "replies": "={{ $json.replies }}",
            "reposts": "={{ $json.reposts }}",
            "user_id": "={{ $json.user_id }}",
            "hashtags": "={{ $json.hashtags }}",
            "followers": "={{ $json.followers }}",
            "following": "={{ $json.following }}",
            "timestamp": "={{ $json.timestamp }}",
            "date_posted": "={{ $json.date_posted }}",
            "description": "={{ $json.description }}",
            "is_verified": "={{ $json.is_verified }}",
            "posts_count": "={{ $json.posts_count }}",
            "quoted_post": "={{ $json.quoted_post }}",
            "user_posted": "={{ $json.user_posted }}",
            "tagged_users": "={{ $json.tagged_users }}",
            "profile_image_link": "={{ $json.profile_image_link }}",
            "external_image_urls": "={{ $json.external_image_urls }}",
            "external_video_urls": "={{ $json.external_video_urls }}"
          },
          "schema": [
            {
              "id": "id",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "id",
              "defaultMatch": true,
              "canBeUsedToMatch": true
            },
            {
              "id": "user_posted",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "user_posted",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "name",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "name",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "description",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "description",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "date_posted",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "date_posted",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "photos",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "photos",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "url",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "url",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "quoted_post",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "quoted_post",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "tagged_users",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "tagged_users",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "replies",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "replies",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "reposts",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "reposts",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "likes",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "likes",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "views",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "views",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "external_url",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "external_url",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "hashtags",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "hashtags",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "followers",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "followers",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "posts_count",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "posts_count",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "profile_image_link",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "profile_image_link",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "following",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "following",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "is_verified",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "is_verified",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "quotes",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "quotes",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "parent_post_details",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "parent_post_details",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "external_image_urls",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "external_image_urls",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "videos",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "videos",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "external_video_urls",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "external_video_urls",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "user_id",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "user_id",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "timestamp",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "timestamp",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "id"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "append",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/YOUR_GOOGLE_SHEET_ID/edit#gid=0",
          "cachedResultName": "Sheet1"
        },
        "documentId": {
          "__rl": true,
          "mode": "url",
          "value": "YOUR_GOOGLE_SHEET_ID"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "YOUR_GOOGLE_SHEETS_CREDENTIAL_ID",
          "name": "Google Sheets OAuth2"
        }
      },
      "typeVersion": 4.6
    },
    {
      "id": "eda5f904-6e95-4ffa-b894-e13915991745",
      "name": "便签 6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        128,
        -64
      ],
      "parameters": {
        "color": 7,
        "width": 256,
        "height": 240,
        "content": "→ 将帖子数据(点赞、回复、用户等)保存到 Sheet"
      },
      "typeVersion": 1
    },
    {
      "id": "1681773c-b304-4a73-a4a2-0406ae9090e5",
      "name": "## 为什么选择 4o 模型?👆",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1328,
        -272
      ],
      "parameters": {
        "content": "创建一个包含以下列的 Google Sheet:"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "0e65c515-c16f-4470-85ee-1a3a64017e80",
  "connections": {
    "✅ Is Scraping Ready?": {
      "main": [
        [
          {
            "node": "📦 Fetch Twitter Data",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "🔄 Monitor Scraping Progress",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "📥 User Input Trigger": {
      "main": [
        [
          {
            "node": "🚀 Trigger Twitter Scraping",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "📦 Fetch Twitter Data": {
      "main": [
        [
          {
            "node": "📊 Store Twitter Data in Google Sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "⏱️ Delay Before Recheck": {
      "main": [
        [
          {
            "node": "✅ Is Scraping Ready?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "🚀 Trigger Twitter Scraping": {
      "main": [
        [
          {
            "node": "🔄 Monitor Scraping Progress",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "🔄 Monitor Scraping Progress": {
      "main": [
        [
          {
            "node": "⏱️ Delay Before Recheck",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

中级 - 市场调研

需要付费吗?

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

工作流信息
难度等级
中级
节点数量15
分类1
节点类型6
难度说明

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

外部链接
在 n8n.io 查看

分享此工作流