8
n8n 中文网amn8n.com

通过Bright Data进行竞争对手价格监控

中级

这是一个AI领域的自动化工作流,包含 15 个节点。主要使用 If, Code, Html, Gmail, HttpRequest 等节点,结合人工智能技术实现智能自动化。 使用Bright Data和n8n的自动竞争对手价格监控

前置要求
  • Google 账号和 Gmail API 凭证
  • 可能需要目标 API 的认证凭证
  • Google Sheets API 凭证
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "id": "6RP5sxs8BvIIinq2",
  "meta": {
    "instanceId": "60046904b104f0f72b2629a9d88fe9f676be4035769f1f08dad1dd38a76b9480"
  },
  "name": "通过 Bright Data 进行竞争对手价格监控",
  "tags": [],
  "nodes": [
    {
      "id": "0fa21dc1-fae9-45ca-b2a9-8c4dc212c964",
      "name": "每日检查价格",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        -1400,
        1000
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "triggerAtHour": 9
            }
          ]
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "58e4effc-32b1-4767-bc79-1f5147a00c4e",
      "name": "通过 Bright Data 获取页面",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -1180,
        1000
      ],
      "parameters": {
        "url": "https://api.brightdata.com/request",
        "method": "POST",
        "options": {},
        "jsonBody": "{\n  \"zone\": \"n8n_unblocker\",\n  \"url\": \"https://www.shopify.com/uk/pricing\",\n  \"country\": \"us\",\n  \"format\": \"raw\",\n  \"headers\": {\n    \"User-Agent\": \"Mozilla/5.0\",\n    \"Accept\": \"text/html\"\n  }\n}",
        "sendBody": true,
        "sendHeaders": true,
        "specifyBody": "json",
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "Bearer API_KEY"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "d1bfc4d4-5951-459f-8dd9-65cbeee325ea",
      "name": "提取 HTML 内容",
      "type": "n8n-nodes-base.html",
      "position": [
        -960,
        1000
      ],
      "parameters": {
        "options": {},
        "operation": "extractHtmlContent",
        "extractionValues": {
          "values": [
            {
              "key": "Plan name",
              "cssSelector": "h3",
              "returnArray": true
            },
            {
              "key": "Pricing",
              "cssSelector": "span",
              "returnArray": true
            }
          ]
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "4983085d-a355-4f1a-8141-cbb622e94776",
      "name": "格式化并隔离价格块",
      "type": "n8n-nodes-base.code",
      "position": [
        -760,
        1000
      ],
      "parameters": {
        "jsCode": "// Step 1: Get data from the previous node\nconst inputData = items[0].json;\n\n// Extract plan names and pricing blocks\nconst planNames = inputData[\"Plan name\"];\nconst pricingList = inputData[\"Pricing\"];\n\n// Regex to match entries like \"$2,300USD/month\"\nconst priceRegex = /\\$[\\d,]+USD\\/month/;\n\n// Step 2: Extract only valid price strings\nconst prices = pricingList.filter(item => typeof item === 'string' && priceRegex.test(item));\n\n// Clean prices: \"$2,300USD/month\" -> 2300 (number)\nconst cleanedPrices = prices.map(p => {\n  const match = p.match(/\\$[\\d,]+/);\n  if (match) {\n    return parseFloat(match[0].replace(/[$,]/g, ''));\n  }\n  return null;\n}).filter(p => p !== null);\n\n// Step 3: Build result object\nconst planPriceMap = {};\n\nfor (let i = 0; i < planNames.length; i++) {\n  const plan = planNames[i];\n\n  if (['Basic', 'Grow', 'Advanced', 'Plus'].includes(plan) && !(plan in planPriceMap)) {\n    planPriceMap[plan] = cleanedPrices.shift() ?? null;\n  }\n}\n\n// Step 4: Return final structured item\nreturn [\n  {\n    json: planPriceMap\n  }\n];\n"
      },
      "typeVersion": 2
    },
    {
      "id": "178945da-4167-43d1-af20-f3acb8003f17",
      "name": "读取最后保存的价格",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        -520,
        1000
      ],
      "parameters": {
        "options": {},
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1LTGVeEXaU1PSMcNWI6beT_IuETKH147vfi8vAtWJ0MQ/edit#gid=0",
          "cachedResultName": "Sheet1"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1LTGVeEXaU1PSMcNWI6beT_IuETKH147vfi8vAtWJ0MQ",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1LTGVeEXaU1PSMcNWI6beT_IuETKH147vfi8vAtWJ0MQ/edit?usp=drivesdk",
          "cachedResultName": "Competitor price analyzer"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "r2mDaisH6e9VkwHl",
          "name": "Google Sheets account"
        }
      },
      "typeVersion": 4.6
    },
    {
      "id": "67534ae0-f365-4e11-b244-73cc999ed47a",
      "name": "价格是否发生变化?",
      "type": "n8n-nodes-base.if",
      "position": [
        -300,
        1000
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "2ca35690-3534-40c4-8d79-02833e331e17",
              "operator": {
                "type": "number",
                "operation": "equals"
              },
              "leftValue": "={{ $('Format & Isolate Price Block').item.json.Basic }}",
              "rightValue": "={{ $json.Basic }}"
            },
            {
              "id": "fe7e3cac-d614-4962-82a4-d3e06464ae14",
              "operator": {
                "type": "number",
                "operation": "equals"
              },
              "leftValue": "={{ $('Format & Isolate Price Block').item.json.Grow }}",
              "rightValue": "={{ $json.Grow }}"
            },
            {
              "id": "bf877945-b2f4-48f9-be88-c3e97600c984",
              "operator": {
                "type": "number",
                "operation": "equals"
              },
              "leftValue": "={{ $('Format & Isolate Price Block').item.json.Advanced }}",
              "rightValue": "={{ $json.Advanced }}"
            },
            {
              "id": "5045eaa9-4798-4ca8-83e3-6c8c51a297d2",
              "operator": {
                "type": "number",
                "operation": "equals"
              },
              "leftValue": "={{ $('Format & Isolate Price Block').item.json.Plus }}",
              "rightValue": "={{ $json.Plus }}"
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "023f6e01-6625-4310-a61f-4dac9748c19d",
      "name": "未检测到变化 – 停止",
      "type": "n8n-nodes-base.noOp",
      "position": [
        60,
        800
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "eaf629e8-eb2d-49b2-a568-a87c52dbe131",
      "name": "更新存储的价格",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        60,
        1180
      ],
      "parameters": {
        "columns": {
          "value": {
            "Grow": "={{ $json.Grow }}",
            "Plus": "={{ $json.Plus }}",
            "Basic": "={{ $json.Basic }}",
            "Advanced": "={{ $json.Advanced }}",
            "row_number": "={{ $json.row_number }}"
          },
          "schema": [
            {
              "id": "Basic",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Basic",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Grow",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Grow",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Advanced",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Advanced",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Plus",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Plus",
              "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": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1LTGVeEXaU1PSMcNWI6beT_IuETKH147vfi8vAtWJ0MQ/edit#gid=0",
          "cachedResultName": "Sheet1"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1LTGVeEXaU1PSMcNWI6beT_IuETKH147vfi8vAtWJ0MQ",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1LTGVeEXaU1PSMcNWI6beT_IuETKH147vfi8vAtWJ0MQ/edit?usp=drivesdk",
          "cachedResultName": "Competitor price analyzer"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "r2mDaisH6e9VkwHl",
          "name": "Google Sheets account"
        }
      },
      "typeVersion": 4.6
    },
    {
      "id": "7505ca0e-f968-437e-a4ca-0cdbd4fee93b",
      "name": "发送价格变化提醒邮件",
      "type": "n8n-nodes-base.gmail",
      "position": [
        280,
        1180
      ],
      "webhookId": "b2bf0aba-123e-489e-9669-4034d16a060c",
      "parameters": {
        "sendTo": "shahkar.genai@gmail.com",
        "message": "=<p>Hi Team,</p>  <p>This is an automated alert to inform you that the pricing page of a competitor has changed.</p>  <ul>   <li><strong>Competitor:</strong> Wix</li>   <li><strong>Page URL:</strong> <a href=\"https://www.wix.com/upgrade/website\">https://www.wix.com/upgrade/website</a></li>   <li><strong>Checked On:</strong> {{ $now }}</li> </ul>  <p>Please review the new pricing to assess if any strategic adjustments are needed.\nPlease check in Google sheets for the latest pricing as soon as possible\n</p>  <p>Best regards,<br>Muhammad Shahkar </p>",
        "options": {
          "appendAttribution": false
        },
        "subject": "Competitor Pricing Page Has Changed"
      },
      "credentials": {
        "gmailOAuth2": {
          "id": "AQDSl75AdzK3vmqJ",
          "name": "Gmail account"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "494ab1e4-de04-4a98-acca-a0e8e242575c",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1460,
        640
      ],
      "parameters": {
        "color": 6,
        "width": 840,
        "height": 540,
        "content": "---"
      },
      "typeVersion": 1
    },
    {
      "id": "a9beb646-c639-408c-a3c4-678e19e7bee2",
      "name": "便签1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -580,
        520
      ],
      "parameters": {
        "color": 3,
        "width": 440,
        "height": 660,
        "content": "---"
      },
      "typeVersion": 1
    },
    {
      "id": "cdb1ef33-fcbb-449d-b81e-b7f8cbaf7a18",
      "name": "便签2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        0,
        0
      ],
      "parameters": {
        "color": 5,
        "width": 440,
        "height": 1360,
        "content": "---"
      },
      "typeVersion": 1
    },
    {
      "id": "afc23ae0-ef5e-490a-980b-a56e9436fa31",
      "name": "便签9",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -3160,
        640
      ],
      "parameters": {
        "color": 4,
        "width": 1300,
        "height": 320,
        "content": "======================================="
      },
      "typeVersion": 1
    },
    {
      "id": "4a1af414-b88b-4618-970e-0b2e67beda67",
      "name": "便签4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -3160,
        980
      ],
      "parameters": {
        "color": 4,
        "width": 1289,
        "height": 1798,
        "content": "---"
      },
      "typeVersion": 1
    },
    {
      "id": "eb40dc03-c451-4442-9742-90ca7aa11f16",
      "name": "便签5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        520,
        0
      ],
      "parameters": {
        "color": 7,
        "width": 380,
        "height": 240,
        "content": "## 如果您通过此链接加入 Bright Data,我将获得少量佣金 — 感谢您为更多免费内容提供动力!"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "10b3a37b-12c0-4a26-a058-b9950a6e26ff",
  "connections": {
    "Has Price Changed?": {
      "main": [
        [
          {
            "node": "No Change Detected – Stop",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Update Stored Price",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Update Stored Price": {
      "main": [
        [
          {
            "node": "Send Price Change Alert Email",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract HTML Content": {
      "main": [
        [
          {
            "node": "Format & Isolate Price Block",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Read Last Saved Price": {
      "main": [
        [
          {
            "node": "Has Price Changed?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check Pricing Every Day": {
      "main": [
        [
          {
            "node": "Fetch Page via Bright Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch Page via Bright Data": {
      "main": [
        [
          {
            "node": "Extract HTML Content",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Format & Isolate Price Block": {
      "main": [
        [
          {
            "node": "Read Last Saved Price",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

中级 - 人工智能

需要付费吗?

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

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

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

作者
Yaron Been

Yaron Been

@yaron-nofluff

Building AI Agents and Automations | Growth Marketer | Entrepreneur | Book Author & Podcast Host If you need any help with Automations, feel free to reach out via linkedin: https://www.linkedin.com/in/yaronbeen/ And check out my Youtube channel: https://www.youtube.com/@YaronBeen/videos

外部链接
在 n8n.io 查看

分享此工作流