8
n8n 中文网amn8n.com

自动化房地产房源提取器

中级

这是一个Market Research领域的自动化工作流,包含 7 个节点。主要使用 Code, GoogleSheets, ScheduleTrigger, Scrapeless 等节点。 使用Scrapeless和Google表格自动化房地产房源抓取

前置要求
  • Google Sheets API 凭证
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "id": "EgeVsV76EKfXbkcW",
  "meta": {
    "instanceId": "7d291de9dc3bbf0106d65e069919a3de2507e3365a7b25788a79a3562af9bfc5"
  },
  "name": "自动化房地产房源提取器",
  "tags": [],
  "nodes": [
    {
      "id": "337aabda-3017-4057-8383-6855837d5e9a",
      "name": "每周市场触发器",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        60,
        780
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "weeks",
              "triggerAtDay": [
                1
              ],
              "triggerAtHour": 9
            }
          ]
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "2be97af8-6121-4cbc-9239-1901d947d8e2",
      "name": "便签3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        0,
        0
      ],
      "parameters": {
        "color": 6,
        "width": 620,
        "height": 1160,
        "content": "## 🔹 **第一部分:🔁 计划触发器 — 自动化工作流**"
      },
      "typeVersion": 1
    },
    {
      "id": "ce4de51e-920e-4e72-9aee-13f2180952fc",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        660,
        -380
      ],
      "parameters": {
        "color": 5,
        "width": 700,
        "height": 1540,
        "content": ""
      },
      "typeVersion": 1
    },
    {
      "id": "3cb24f03-3bc2-4ca9-9234-9dc2ab9c36a2",
      "name": "爬取",
      "type": "n8n-nodes-scrapeless.scrapeless",
      "position": [
        360,
        780
      ],
      "parameters": {
        "url": "https://www.loopnet.com/search/commercial-real-estate/los-angeles-ca/for-lease/",
        "resource": "crawler",
        "operation": "crawl",
        "limitCrawlPages": 2
      },
      "credentials": {
        "scrapelessApi": {
          "id": "B73pdQXNjpqNbIhs",
          "name": "Scrapeless account"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "64cbc99c-e071-4c0d-8758-a0e5167f4c88",
      "name": "在表格中追加或更新行",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        1580,
        780
      ],
      "parameters": {
        "columns": {
          "value": {
            "Link": "={{ $json.link }}",
            "Size": "={{ $json.size }}",
            "Image": "={{ $json.image }}",
            "Title": "={{ $json.title }}",
            "YearBuilt": "={{ $json.yearBuilt }}"
          },
          "schema": [
            {
              "id": "Title",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Title",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Link",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Link",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Size",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Size",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "YearBuilt",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "YearBuilt",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Image",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Image",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "Title"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "appendOrUpdate",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1of_9PIseDnbwGYiJ5SLx3bSU5m8TTXpBN6haS2f7EBY/edit#gid=0",
          "cachedResultName": "Sheet1"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1of_9PIseDnbwGYiJ5SLx3bSU5m8TTXpBN6haS2f7EBY",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1of_9PIseDnbwGYiJ5SLx3bSU5m8TTXpBN6haS2f7EBY/edit?usp=drivesdk",
          "cachedResultName": "Real Estate Market Report"
        }
      },
      "typeVersion": 4.6
    },
    {
      "id": "0458cbbb-e60b-461d-aed0-562d5067946e",
      "name": "便签1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1420,
        -60
      ],
      "parameters": {
        "width": 580,
        "height": 1220,
        "content": ""
      },
      "typeVersion": 1
    },
    {
      "id": "f0d425e4-af8d-4c6f-bced-625ba3b094f0",
      "name": "解析房源",
      "type": "n8n-nodes-base.code",
      "position": [
        860,
        780
      ],
      "parameters": {
        "jsCode": "const markdownData = [];\n$input.all().forEach((item) => {\n\titem.json.forEach((c) => {\n\t\tmarkdownData.push(c.markdown);\n\t});\n});\n\nconst results = [];\n\nfunction dataExtact(md) {\n\tconst re = /\\[More details for ([^\\]]+)\\]\\((https:\\/\\/www\\.loopnet\\.com\\/Listing\\/[^\\)]+)\\)/g;\n\n\tlet match;\n\n\twhile ((match = re.exec(md))) {\n\t\tconst title = match[1].trim();\n\t\tconst link = match[2].trim()?.split(' ')[0];\n\n\t\t// Extract a snippet of context around the match\n\t\tconst context = md.slice(match.index, match.index + 500);\n\n\t\t// Extract size range, e.g. \"10,000 - 20,000 SF\"\n\t\tconst sizeMatch = context.match(/([\\d,]+)\\s*-\\s*([\\d,]+)\\s*SF/);\n\t\tconst sizeRange = sizeMatch ? `${sizeMatch[1]} - ${sizeMatch[2]} SF` : null;\n\n\t\t// Extract year built, e.g. \"Built in 1988\"\n\t\tconst yearMatch = context.match(/Built in\\s*(\\d{4})/i);\n\t\tconst yearBuilt = yearMatch ? yearMatch[1] : null;\n\n\t\t// Extract image URL\n\t\tconst imageMatch = context.match(/!\\[[^\\]]*\\]\\((https:\\/\\/images1\\.loopnet\\.com[^\\)]+)\\)/);\n\t\tconst image = imageMatch ? imageMatch[1] : null;\n\n\t\tresults.push({\n\t\t\tjson: {\n\t\t\t\ttitle,\n\t\t\t\tlink,\n\t\t\t\tsize: sizeRange,\n\t\t\t\tyearBuilt,\n\t\t\t\timage,\n\t\t\t},\n\t\t});\n\t}\n\n\t// Return original markdown if no matches found (for debugging)\n\tif (results.length === 0) {\n\t\treturn [\n\t\t\t{\n\t\t\t\tjson: {\n\t\t\t\t\terror: 'No listings matched',\n\t\t\t\t\traw: md,\n\t\t\t\t},\n\t\t\t},\n\t\t];\n\t}\n}\n\nmarkdownData.forEach((item) => {\n\tdataExtact(item);\n});\n\nreturn results;\n"
      },
      "typeVersion": 2
    }
  ],
  "active": false,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "3bbe4fe1-455d-4486-af39-d0980957100e",
  "connections": {
    "Crawl": {
      "main": [
        [
          {
            "node": "Parse Listings",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Parse Listings": {
      "main": [
        [
          {
            "node": "Append or update row in sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Weekly Market Trigger": {
      "main": [
        [
          {
            "node": "Crawl",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

中级 - 市场调研

需要付费吗?

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

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

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

外部链接
在 n8n.io 查看

分享此工作流