8
n8n 中文网amn8n.com

财务洞察自动化:通过Bright Data将市值发送到Telegram

中级

这是一个Crypto Trading领域的自动化工作流,包含 14 个节点。主要使用 If, Code, Wait, Telegram, FormTrigger 等节点。 使用Bright Data从Yahoo Finance提取市值数据并在Telegram中可视化

前置要求
  • Telegram Bot Token
  • 可能需要目标 API 的认证凭证
  • Google Sheets API 凭证
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "id": "k2FvKOkV5UgBEnCu",
  "meta": {
    "instanceId": "bc8ca75c203589705ae2e446cad7181d6f2a7cc1766f958ef9f34810e53b8cb2"
  },
  "name": "财务洞察自动化:通过 Bright Data 将市值发送到 Telegram",
  "tags": [],
  "nodes": [
    {
      "id": "7cebf294-ed28-4cce-935f-8182c953aa5d",
      "name": "🟩 表单触发器",
      "type": "n8n-nodes-base.formTrigger",
      "position": [
        -1440,
        16
      ],
      "webhookId": "92772d3e-a1e1-4912-996a-7e799f129fb8",
      "parameters": {
        "options": {},
        "formTitle": "Yahoo",
        "formFields": {
          "values": [
            {
              "fieldLabel": "keyword"
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "21b115c8-d3a7-4c6e-b3af-aab2e2c7f7d1",
      "name": "🚀 触发抓取1(HTTP 请求到 Bright Data)",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -1184,
        16
      ],
      "parameters": {
        "url": "https://api.brightdata.com/datasets/v3/trigger",
        "method": "POST",
        "options": {},
        "jsonBody": "=[\n  {\n    \"keyword\": \"{{ $json.keyword }}\"\n  } \n]",
        "sendBody": true,
        "sendQuery": true,
        "sendHeaders": true,
        "specifyBody": "json",
        "queryParameters": {
          "parameters": [
            {
              "name": "dataset_id",
              "value": "gd_lmrpz3vxmz972ghd7"
            },
            {
              "name": "include_errors",
              "value": "true"
            },
            {
              "name": "type",
              "value": "discover_new"
            },
            {
              "name": "discover_by",
              "value": "keyword"
            },
            {
              "name": "limit_per_input",
              "value": "2"
            }
          ]
        },
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "Bearer BRIGHT_DATA_API_KEY"
            }
          ]
        }
      },
      "typeVersion": 4.2,
      "alwaysOutputData": true
    },
    {
      "id": "75b8a695-9ad8-4d55-8cee-e6ebfda0defd",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1488,
        -144
      ],
      "parameters": {
        "color": 7,
        "width": 448,
        "height": 368,
        "content": "🟩 表单触发器(在表单提交1时)"
      },
      "typeVersion": 1
    },
    {
      "id": "db304f8b-91e1-4d33-acc9-0ba8351160da",
      "name": "🕐 等待 1 分钟1",
      "type": "n8n-nodes-base.wait",
      "position": [
        -720,
        16
      ],
      "webhookId": "10b45556-5e91-4387-abd0-f9078b220286",
      "parameters": {
        "unit": "minutes",
        "amount": 1
      },
      "typeVersion": 1.1
    },
    {
      "id": "c0a0422f-a712-4be9-b46d-c35e6b5956ce",
      "name": "🟡 检查 Snap ID1 的交付状态",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -960,
        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": "a23cf845-6bff-4a40-a87f-5d0bac918acc",
      "name": "🟢 检查最终状态",
      "type": "n8n-nodes-base.if",
      "position": [
        -480,
        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": "4d719ca5-ae7f-44b2-8b63-ed8a729ebbbb",
      "name": "🔽 给出的最终数据(快照获取)",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -240,
        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": "6efc936b-cfa4-431f-81a0-fd6536bd3072",
      "name": "便签1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1008,
        -240
      ],
      "parameters": {
        "color": 3,
        "width": 688,
        "height": 464,
        "content": "⏳ 区域 2:监控和获取结果"
      },
      "typeVersion": 1
    },
    {
      "id": "438a38f6-c401-4b75-94c6-e15992a97e76",
      "name": "📊 过滤输出并保存到表格",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        -16,
        0
      ],
      "parameters": {
        "columns": {
          "value": {
            "ask": "={{ $json.ask }}",
            "bid": "={{ $json.bid }}",
            "eps": "={{ $json.eps }}",
            "url": "={{ $json.url }}",
            "beta": "={{ $json.pe_ratio }}",
            "name": "={{ $json.name }}",
            "open": "={{ $json.open }}",
            "input": "={{ $json.input }}",
            "volume": "={{ $json.volume }}",
            "similar": "={{ $json.similar }}",
            "summary": "={{ $json.summary }}",
            "currency": "={{ $json.currency }}",
            "exchange": "={{ $json.exchange }}",
            "day_range": "={{ $json.day_range }}",
            "eps_trend": "={{ $json.eps_trend }}",
            "timestamp": "={{ $json.timestamp }}",
            "avg_volume": "={{ $json.avg_volume }}",
            "company_id": "={{ $json.company_id }}",
            "financials": "={{ $json.financials }}",
            "market_cap": "={{ $json.market_cap }}",
            "target_est": "={{ $json.target_est }}",
            "week_range": "={{ $json.week_range }}",
            "entity_type": "={{ $json.entity_type }}",
            "recent_news": "={{ $json.recent_news }}",
            "stock_ticker": "={{ $json.stock_ticker }}",
            "top_analysts": "={{ $json.top_analysts }}",
            "closing_price": "={{ $json.closing_price }}",
            "earnings_date": "={{ $json.earnings_date }}",
            "eps_revisions": "={{ $json.eps_revisions }}",
            "dividend_yield": "={{ $json.dividend_yield }}",
            "previous_close": "={{ $json.previous_close }}",
            "discovery_input": "={{ $json.discovery_input }}",
            "earnings_history": "={{ $json.earnings_history }}",
            "growth_estimates": "={{ $json.growth_estimates }}",
            "revenue_estimate": "={{ $json.revenue_estimate }}",
            "earnings_estimate": "={{ $json.earnings_estimate }}",
            "people_also_watch": "={{ $json.people_also_watch }}",
            "fanacials_currency": "={{ $json.fanacials_currency }}",
            "stock_market_index": "={{ $json.stock_market_index }}",
            "analyst_price_target": "={{ $json.analyst_price_target }}",
            "financials_quarterly": "={{ $json.financials_quarterly }}",
            "company_profile_phone": "={{ $json.company_profile_phone }}",
            "company_profile_sector": "={{ $json.company_profile_sector }}",
            "company_profile_address": "={{ $json.company_profile_address }}",
            "company_profile_website": "={{ $json.company_profile_website }}",
            "upgrades_and_downgrades": "={{ $json.upgrades_and_downgrades }}",
            "company_profile_industry": "={{ $json.company_profile_industry }}",
            "company_profile_employees": "={{ $json.company_profile_key_executives }}",
            "company_profile_description": "={{ $json.company_profile_description }}",
            "company_profile_key_executives": "={{ $json.company_profile_key_executives }}"
          },
          "schema": [
            {
              "id": "name",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "name",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": []
        },
        "options": {},
        "operation": "append",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/YOUR_SHEET_ID/edit#gid=0",
          "cachedResultName": "Sheet1"
        },
        "documentId": {
          "__rl": true,
          "mode": "url",
          "value": "=https://docs.google.com/spreadsheets/d/YOUR_SHEET_ID/edit?gid=0#gid=0"
        }
      },
      "credentials": {},
      "typeVersion": 4.6
    },
    {
      "id": "eb1997f3-3a09-417b-9ea6-86861ec5c1df",
      "name": "便签2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -288,
        -256
      ],
      "parameters": {
        "color": 4,
        "width": 432,
        "height": 480,
        "content": "📊 区域 3:过滤和输出"
      },
      "typeVersion": 1
    },
    {
      "id": "87619346-06ed-4311-a7e0-bcb82f554aca",
      "name": "🧮 生成图表载荷",
      "type": "n8n-nodes-base.code",
      "position": [
        240,
        0
      ],
      "parameters": {
        "jsCode": "const itemsOut = [];\n\nconst labels = [];\nconst data = [];\n\nfor (const item of items) {\n  const name = item.json.name;\n  let cap = item.json.market_cap;\n  if (cap === undefined || cap === null) cap = \"0\";\n  cap = String(cap);\n\n  let value = 0;\n  if (cap.includes(\"T\")) value = parseFloat(cap) * 1e12;\n  else if (cap.includes(\"B\")) value = parseFloat(cap) * 1e9;\n  else if (cap.includes(\"M\")) value = parseFloat(cap) * 1e6;\n  else value = parseFloat(cap);\n\n  labels.push(name);\n  data.push(Math.round(value / 1e9));\n}\n\nconst chartPayload = {\n  type: 'bar',\n  data: {\n    labels,\n    datasets: [{\n      label: 'Market Cap (in Billion $)',\n      data,\n      backgroundColor: [\n        'rgba(75, 192, 192, 0.8)',\n        'rgba(153, 102, 255, 0.8)',\n        'rgba(255, 159, 64, 0.8)',\n        'rgba(255, 99, 132, 0.8)',\n        'rgba(54, 162, 235, 0.8)',\n        'rgba(201, 203, 207, 0.8)'\n      ],\n      borderColor: 'rgba(0,0,0,0.1)',\n      borderWidth: 1\n    }]\n  },\n  options: {\n    indexAxis: 'y',\n    responsive: true,\n    plugins: {\n      legend: {\n        display: false\n      },\n      title: {\n        display: true,\n        text: '📊 Company Market Cap Overview',\n        font: {\n          size: 20\n        },\n        padding: {\n          top: 10,\n          bottom: 20\n        }\n      },\n      tooltip: {\n        callbacks: {\n          label: function(context) {\n            return context.dataset.label + ': $' + context.raw + 'B';\n          }\n        }\n      }\n    },\n    scales: {\n      x: {\n        title: {\n          display: true,\n          text: 'Market Cap (in Billions $)'\n        },\n        grid: {\n          display: true\n        }\n      },\n      y: {\n        ticks: {\n          font: {\n            size: 12\n          }\n        }\n      }\n    }\n  }\n};\n\nitemsOut.push({ json: { chart: chartPayload } });\nreturn itemsOut;"
      },
      "typeVersion": 2
    },
    {
      "id": "a4c79ae7-ef35-4509-91f5-71107fcfee20",
      "name": "🌐 从图表生成 PNG",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        448,
        0
      ],
      "parameters": {
        "url": "=https://quickchart.io/chart?c={{ JSON.stringify($json.chart) }}",
        "options": {}
      },
      "typeVersion": 4.2
    },
    {
      "id": "405f8c35-7747-442b-a14f-898a2b366d0e",
      "name": "📤 在 Telegram 上发送图表",
      "type": "n8n-nodes-base.telegram",
      "position": [
        656,
        0
      ],
      "webhookId": "d7190374-fdad-4ccd-ab58-77794a247fb1",
      "parameters": {
        "chatId": "YOUR_TELEGRAM_CHAT_ID",
        "operation": "sendPhoto",
        "binaryData": true,
        "additionalFields": {}
      },
      "credentials": {},
      "typeVersion": 1.2
    },
    {
      "id": "01b96865-6ae1-43d8-962d-2a7141f9254f",
      "name": "便签3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        208,
        -256
      ],
      "parameters": {
        "width": 624,
        "height": 480,
        "content": "1.🧮 生成图表载荷(代码节点)"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "514d9f62-1953-40f2-bf5d-9b00b95ded68",
  "connections": {
    "🟩 Form Trigger": {
      "main": [
        [
          {
            "node": "🚀 Trigger Scraping1 (HTTP Request to Bright Data)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "🕐 Wait 1 minute1": {
      "main": [
        [
          {
            "node": "🟢 Check Final Status",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "🟢 Check Final Status": {
      "main": [
        [
          {
            "node": "🔽 final data given (Snapshot Fetch)",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "🟡 Check Delivery Status of Snap ID1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "🧮 Generate Chart Payload": {
      "main": [
        [
          {
            "node": "🌐 Generate PNG from Chart",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "🌐 Generate PNG from Chart": {
      "main": [
        [
          {
            "node": "📤 Send Chart on Telegram",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "📊 Filtered Output & Save to Sheet": {
      "main": [
        [
          {
            "node": "🧮 Generate Chart Payload",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "🔽 final data given (Snapshot Fetch)": {
      "main": [
        [
          {
            "node": "📊 Filtered Output & Save to Sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "🟡 Check Delivery Status of Snap ID1": {
      "main": [
        [
          {
            "node": "🕐 Wait 1 minute1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "🚀 Trigger Scraping1 (HTTP Request to Bright Data)": {
      "main": [
        [
          {
            "node": "🟡 Check Delivery Status of Snap ID1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

中级 - 加密货币交易

需要付费吗?

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

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

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

外部链接
在 n8n.io 查看

分享此工作流