从 Google 搜索和地图自动生成潜在客户到 Google Sheets
高级
这是一个自动化工作流,包含 40 个节点。主要使用 If, Set, Code, Wait, Merge 等节点。 从 Google 搜索和地图自动生成潜在客户到 Google Sheets
前置要求
- •可能需要目标 API 的认证凭证
- •Google Sheets API 凭证
使用的节点 (40)
分类
-
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
"id": "J3HFTy4HBCyARaO4",
"meta": {
"instanceId": "1a54c41d9050a8f1fa6f74ca858828ad9fb97b9fafa3e9760e576171c531a787"
},
"name": "从 Google 搜索和地图自动生成潜在客户到 Google Sheets",
"tags": [
{
"id": "m1paRrANi4GrQXxX",
"name": "AI Internal",
"createdAt": "2025-09-18T04:05:25.667Z",
"updatedAt": "2025-09-18T04:05:25.667Z"
}
],
"nodes": [
{
"id": "9f1247da-3797-481a-b835-a5c780b050d4",
"name": "当收到聊天消息时",
"type": "@n8n/n8n-nodes-langchain.chatTrigger",
"position": [
-1344,
496
],
"webhookId": "7058453f-20ea-4f70-b9b8-0e4063a52ad2",
"parameters": {
"options": {}
},
"typeVersion": 1.3
},
{
"id": "f8df5c5f-af30-4f62-9aab-e010dd9c9c91",
"name": "条件判断",
"type": "n8n-nodes-base.if",
"position": [
256,
-96
],
"parameters": {
"options": {},
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "79d732fc-8a88-4a84-8a18-8cc9b689b3c0",
"operator": {
"type": "string",
"operation": "notEmpty",
"singleValue": true
},
"leftValue": "={{ $json[\"Email ID\"] }}",
"rightValue": ""
}
]
}
},
"typeVersion": 2.2
},
{
"id": "a496c6f6-fa85-4a33-85f4-98e9b00f4af2",
"name": "在表格中追加行",
"type": "n8n-nodes-base.googleSheets",
"position": [
880,
-128
],
"parameters": {
"columns": {
"value": {
"URL": "={{ $json.URL }}",
"Type": "={{ $json.Type }}",
"Socials": "={{ $json.Socials }}",
"Description": "={{ $json.Description }}",
"Search Query": "={{ $('When chat message received').item.json.chatInput }}",
"Business Name": "={{ $json[\"Business Name\"] }}",
"Primary Email": "={{ $json[\"Email ID\"] }}",
"Contact Number": "={{ $json[\"Contact Number\"] }}"
},
"schema": [
{
"id": "Search Query",
"type": "string",
"display": true,
"required": false,
"displayName": "Search Query",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "Business Name",
"type": "string",
"display": true,
"required": false,
"displayName": "Business Name",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "Primary Email",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "Primary Email",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "Rest Email",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "Rest Email",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "Contact Number",
"type": "string",
"display": true,
"required": false,
"displayName": "Contact Number",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "URL",
"type": "string",
"display": true,
"required": false,
"displayName": "URL",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "Description",
"type": "string",
"display": true,
"required": false,
"displayName": "Description",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "Type",
"type": "string",
"display": true,
"required": false,
"displayName": "Type",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "Socials",
"type": "string",
"display": true,
"required": false,
"displayName": "Socials",
"defaultMatch": false,
"canBeUsedToMatch": true
}
],
"mappingMode": "defineBelow",
"matchingColumns": [],
"attemptToConvertTypes": false,
"convertFieldsToString": false
},
"options": {},
"operation": "append",
"sheetName": {
"__rl": true,
"mode": "list",
"value": "gid=0",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/1JvDSWt5K1Cc9wCd36MADVbh4tu4KdPAzVlMUstv_ou8/edit#gid=0",
"cachedResultName": "Sheet1"
},
"documentId": {
"__rl": true,
"mode": "list",
"value": "1JvDSWt5K1Cc9wCd36MADVbh4tu4KdPAzVlMUstv_ou8",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/1JvDSWt5K1Cc9wCd36MADVbh4tu4KdPAzVlMUstv_ou8/edit?usp=drivesdk",
"cachedResultName": "Leads Via Google Search"
}
},
"typeVersion": 4.7
},
{
"id": "82cf4f94-509f-4698-9982-af48caa035de",
"name": "移除重复项",
"type": "n8n-nodes-base.removeDuplicates",
"position": [
1056,
1136
],
"parameters": {
"options": {}
},
"typeVersion": 2
},
{
"id": "ff0491b3-1695-48be-863d-d7e8bd6529cd",
"name": "遍历项目",
"type": "n8n-nodes-base.splitInBatches",
"position": [
1312,
1104
],
"parameters": {
"options": {}
},
"typeVersion": 3
},
{
"id": "d441d472-e687-44d7-9ddb-fb1f8baa7c45",
"name": "提取 URL",
"type": "n8n-nodes-base.code",
"position": [
592,
1120
],
"parameters": {
"jsCode": "const input = $input.first().json.data\nconst regex = /https?:\\/\\/[^\\/\\s\"'>]+/g\nconst websites = input.match(regex)\nreturn websites.map(website => ({json:{website}}))"
},
"typeVersion": 2
},
{
"id": "30354b5f-e671-42fb-be46-38dcd63a6b10",
"name": "抓取 Google 地图",
"type": "n8n-nodes-base.httpRequest",
"position": [
368,
1136
],
"parameters": {
"url": "=https://www.google.com/maps/search/{{ $json.searchQuery }}",
"options": {
"response": {
"response": {
"fullResponse": true
}
},
"allowUnauthorizedCerts": true
}
},
"typeVersion": 4.2
},
{
"id": "bdba745f-cec0-4df6-8f95-cff4eb9ea1ff",
"name": "过滤 Google URL",
"type": "n8n-nodes-base.filter",
"position": [
832,
1136
],
"parameters": {
"options": {},
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "bf0a5053-9660-457c-9581-964793bb6d7d",
"operator": {
"type": "string",
"operation": "notContains"
},
"leftValue": "={{ $json.website }}",
"rightValue": "schema"
},
{
"id": "9110b9e0-12aa-45cc-bde0-9eda8c10970e",
"operator": {
"type": "string",
"operation": "notContains"
},
"leftValue": "={{ $json.website }}",
"rightValue": "google"
},
{
"id": "fb9b6ed6-96a5-4560-ab10-b8a4b9a61a2b",
"operator": {
"type": "string",
"operation": "notContains"
},
"leftValue": "={{ $json.website }}",
"rightValue": "gg"
},
{
"id": "10500c0b-cdbd-4816-aba3-df60d69845dc",
"operator": {
"type": "string",
"operation": "notContains"
},
"leftValue": "={{ $json.website }}",
"rightValue": "gstatic"
}
]
}
},
"typeVersion": 2.2
},
{
"id": "ed333dd0-1e0d-4c97-8b63-7535427f8a8d",
"name": "等待 2",
"type": "n8n-nodes-base.wait",
"position": [
1696,
1120
],
"webhookId": "19cc6ed4-4fe7-485b-b879-c679e4b3374d",
"parameters": {
"amount": 1
},
"typeVersion": 1.1
},
{
"id": "34b415fd-db46-4914-b005-236b5aaee205",
"name": "获取表格中的行",
"type": "n8n-nodes-base.googleSheets",
"position": [
112,
448
],
"parameters": {
"options": {},
"sheetName": {
"__rl": true,
"mode": "list",
"value": "gid=0",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/1JvDSWt5K1Cc9wCd36MADVbh4tu4KdPAzVlMUstv_ou8/edit#gid=0",
"cachedResultName": "Sheet1"
},
"documentId": {
"__rl": true,
"mode": "list",
"value": "1JvDSWt5K1Cc9wCd36MADVbh4tu4KdPAzVlMUstv_ou8",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/1JvDSWt5K1Cc9wCd36MADVbh4tu4KdPAzVlMUstv_ou8/edit?usp=drivesdk",
"cachedResultName": "Leads Via Google Search"
}
},
"typeVersion": 4.7
},
{
"id": "e631f027-7a37-4899-89d6-0b0c7f18c6fa",
"name": "获取 sheet1 中的行",
"type": "n8n-nodes-base.googleSheets",
"position": [
96,
1760
],
"parameters": {
"options": {},
"sheetName": {
"__rl": true,
"mode": "list",
"value": "gid=0",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/1JvDSWt5K1Cc9wCd36MADVbh4tu4KdPAzVlMUstv_ou8/edit#gid=0",
"cachedResultName": "Sheet1"
},
"documentId": {
"__rl": true,
"mode": "list",
"value": "1JvDSWt5K1Cc9wCd36MADVbh4tu4KdPAzVlMUstv_ou8",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/1JvDSWt5K1Cc9wCd36MADVbh4tu4KdPAzVlMUstv_ou8/edit?usp=drivesdk",
"cachedResultName": "Leads Via Google Search"
}
},
"typeVersion": 4.7
},
{
"id": "cb140551-a551-47ae-97b7-d64048c43be6",
"name": "移除重复项3",
"type": "n8n-nodes-base.removeDuplicates",
"position": [
1296,
1728
],
"parameters": {
"options": {}
},
"typeVersion": 2
},
{
"id": "13770160-49fe-4a3e-b60d-81a9ff86368a",
"name": "在 sheet2 中追加行",
"type": "n8n-nodes-base.googleSheets",
"position": [
1632,
1728
],
"parameters": {
"columns": {
"value": {
"URL": "={{ $json.URL }}",
"Type": "website",
"Socials": "={{ $json.socials }}",
"Rest Email": "={{ $json.email2 }}",
"Description": "={{ $json.description }}",
"Search Query": "={{ $('When chat message received').item.json.chatInput }}",
"Business Name": "={{ $json.businessName }}",
"Primary Email": "={{ $json.email1 }}",
"Contact Number": "={{ $json.phone }}"
},
"schema": [
{
"id": "Search Query",
"type": "string",
"display": true,
"required": false,
"displayName": "Search Query",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "Business Name",
"type": "string",
"display": true,
"required": false,
"displayName": "Business Name",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "Primary Email",
"type": "string",
"display": true,
"required": false,
"displayName": "Primary Email",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "Rest Email",
"type": "string",
"display": true,
"required": false,
"displayName": "Rest Email",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "Contact Number",
"type": "string",
"display": true,
"required": false,
"displayName": "Contact Number",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "URL",
"type": "string",
"display": true,
"required": false,
"displayName": "URL",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "Description",
"type": "string",
"display": true,
"required": false,
"displayName": "Description",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "Type",
"type": "string",
"display": true,
"required": false,
"displayName": "Type",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "Socials",
"type": "string",
"display": true,
"required": false,
"displayName": "Socials",
"defaultMatch": false,
"canBeUsedToMatch": true
}
],
"mappingMode": "defineBelow",
"matchingColumns": [],
"attemptToConvertTypes": false,
"convertFieldsToString": false
},
"options": {},
"operation": "append",
"sheetName": {
"__rl": true,
"mode": "list",
"value": "gid=0",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/1JvDSWt5K1Cc9wCd36MADVbh4tu4KdPAzVlMUstv_ou8/edit#gid=0",
"cachedResultName": "Sheet1"
},
"documentId": {
"__rl": true,
"mode": "list",
"value": "1JvDSWt5K1Cc9wCd36MADVbh4tu4KdPAzVlMUstv_ou8",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/1JvDSWt5K1Cc9wCd36MADVbh4tu4KdPAzVlMUstv_ou8/edit?usp=drivesdk",
"cachedResultName": "Leads Via Google Search"
}
},
"typeVersion": 4.7
},
{
"id": "a1d0ac38-853a-40f1-8268-201e17d3d82e",
"name": "## 如何实施此 n8n 工作流",
"type": "n8n-nodes-base.splitInBatches",
"onError": "continueRegularOutput",
"position": [
608,
368
],
"parameters": {
"options": {}
},
"typeVersion": 3
},
{
"id": "d16c9b61-e5fc-414e-ad4d-6f4b62a3822c",
"name": "设置分页",
"type": "n8n-nodes-base.code",
"position": [
160,
-368
],
"parameters": {
"jsCode": "// Array of start indices for pagination\nconst starts = [ 1, 11, 21, 31];\n\n// Create an array of items, one per start value\nreturn starts.map(s => ({ json: { start: s } }));\n"
},
"typeVersion": 2
},
{
"id": "37cdc904-b273-49f9-b0f1-e00ec4fe2895",
"name": "多页搜索循环",
"type": "n8n-nodes-base.splitInBatches",
"position": [
400,
-368
],
"parameters": {
"options": {}
},
"typeVersion": 3
},
{
"id": "b05aecbc-243e-418f-ab55-cb20e12f5116",
"name": "自定义 Google 搜索 API",
"type": "n8n-nodes-base.httpRequest",
"position": [
704,
-352
],
"parameters": {
"url": "https://www.googleapis.com/customsearch/v1",
"options": {},
"sendQuery": true,
"queryParameters": {
"parameters": [
{
"name": "key",
"value": "AIzaSyBkZbXnx8Vs9YGdQxpIL133ikGEtefx6wI"
},
{
"name": "cx",
"value": "2788643fa0be84497"
},
{
"name": "q",
"value": "={{ $('When chat message received').item.json.chatInput }}"
},
{
"name": "cr",
"value": "countryUS"
},
{
"name": "gl",
"value": "us"
},
{
"name": "lr",
"value": "lang_en"
},
{
"name": "start",
"value": "={{ $json.start }}"
}
]
}
},
"typeVersion": 4.2
},
{
"id": "79df0f3d-6211-4f5f-9b76-263da7db8edb",
"name": "扁平化输出项",
"type": "n8n-nodes-base.code",
"position": [
944,
-352
],
"parameters": {
"jsCode": "// Each input item from HTTP Request node\nreturn $input.all().map(item => {\n // Extract only the 'items' array from the API response\n const results = item.json.items || [];\n\n // Return each search result as a separate item\n return results.map(r => ({\n json: r\n }));\n}).flat();\n"
},
"typeVersion": 2
},
{
"id": "2c3e8958-595e-4e11-9d01-158657691667",
"name": "信息提取",
"type": "n8n-nodes-base.code",
"position": [
1280,
-352
],
"parameters": {
"jsCode": "// For each input item (already a search result)\nreturn $input.all().map(item => {\n const r = item.json;\n const metatags = (r.pagemap && r.pagemap.metatags && r.pagemap.metatags[0]) || {};\n\n return {\n json: {\n \"Business Name\": r.title || null,\n \"Email ID\": metatags['og:email'] || null,\n \"Contact Number\": metatags['og:phone_number'] || null,\n \"URL\": r.link || null,\n \"Description\": r.snippet || metatags['og:description'] || null,\n \"Type\": metatags['og:type'] || null,\n \"Socials\": metatags['og:see_also'] || null\n }\n };\n});\n"
},
"typeVersion": 2
},
{
"id": "e0d64378-c004-44b3-a9d9-cee43a157989",
"name": "从搜索结果中移除重复项",
"type": "n8n-nodes-base.removeDuplicates",
"position": [
1680,
-352
],
"parameters": {
"compare": "selectedFields",
"options": {},
"fieldsToCompare": "=URL"
},
"typeVersion": 2
},
{
"id": "5e59a9c6-6b03-4361-8505-974a74fea15f",
"name": "抓取网站2",
"type": "n8n-nodes-base.httpRequest",
"onError": "continueRegularOutput",
"position": [
944,
352
],
"parameters": {
"url": "={{ $json.URL }}",
"options": {
"redirect": {
"redirect": {
"followRedirects": false
}
},
"response": {
"response": {
"responseFormat": "text"
}
},
"allowUnauthorizedCerts": true
},
"sendHeaders": true,
"headerParameters": {
"parameters": [
{}
]
}
},
"typeVersion": 4.2
},
{
"id": "5cc43a8c-9ae5-49e6-8c55-d5e9839424c7",
"name": "如果网站已抓取",
"type": "n8n-nodes-base.if",
"onError": "continueRegularOutput",
"position": [
1248,
352
],
"parameters": {
"options": {},
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "8cade239-5400-45e5-923d-5bccb689e523",
"operator": {
"type": "string",
"operation": "exists",
"singleValue": true
},
"leftValue": "={{ $json.data }}",
"rightValue": ""
}
]
}
},
"typeVersion": 2.2
},
{
"id": "81d1f254-b195-4ba3-bf85-f14ad3422a1f",
"name": "提取必填字段",
"type": "n8n-nodes-base.code",
"onError": "continueRegularOutput",
"position": [
1488,
336
],
"parameters": {
"jsCode": "// Get current batch of items\nconst items = $input.all();\n\n// Regex patterns\nconst emailRegex = /[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-z]{2,}/g;\nconst phoneRegex = /(?:\\+?\\d{1,2}\\s?)?(?:\\(\\d{3}\\)|\\d{3})[-.\\s]?\\d{3}[-.\\s]?\\d{4}/g;\nconst socialRegex = /(https?:\\/\\/(?:www\\.)?(?:facebook|twitter|instagram|linkedin|youtube)\\.com\\/[^\\s\"'<>]+)/gi;\n\n// Helper to remove duplicates\nfunction uniqueArray(arr) {\n return arr ? [...new Set(arr)] : [];\n}\n\n// Function to extract data\nfunction extractFromHTML(html) {\n const emails = uniqueArray(html.match(emailRegex));\n const phones = uniqueArray(html.match(phoneRegex));\n const socials = uniqueArray(html.match(socialRegex));\n\n return {\n email1: emails.length > 0 ? emails[0] : null,\n email2: emails.length > 1 ? emails.slice(1).join(\", \") : null, // all remaining emails\n phone: phones.length > 0 ? phones.join(\", \") : null, // string instead of array\n socials: socials.length > 0 ? socials.join(\", \") : null // string instead of array\n };\n}\n\n// Process each item\nconst output = items.map(item => {\n const htmlData = item.json.data || \"\"; // assuming HTML content is in 'data'\n const extracted = extractFromHTML(htmlData);\n\n return { json: extracted };\n});\n\nreturn output;\n"
},
"typeVersion": 2,
"alwaysOutputData": false
},
{
"id": "66f68935-9577-4b95-a235-f8a720aa7dc1",
"name": "设置所有字段",
"type": "n8n-nodes-base.set",
"position": [
1776,
336
],
"parameters": {
"options": {},
"assignments": {
"assignments": [
{
"id": "a4dec390-76fa-42b3-acaf-93b2449aaa3f",
"name": "Phone",
"type": "string",
"value": "={{ $json.phone }}"
},
{
"id": "78749360-6d15-42d1-8017-ec626eaeb24b",
"name": "Social",
"type": "string",
"value": "={{ $json.socials }}"
},
{
"id": "f90b4f19-bc8f-4638-96ba-458c0cafe7c5",
"name": "Email1",
"type": "string",
"value": "={{ $json.email1 }}"
},
{
"id": "507b5231-f31b-4587-82dd-eb4c03e44bcd",
"name": "Name",
"type": "string",
"value": "={{ $('Loop Over Items1').item.json[\"Business Name\"] }}"
},
{
"id": "722bf218-e8b5-4e69-8602-bf1b858abc44",
"name": "URL",
"type": "string",
"value": "={{ $('Loop Over Items1').item.json.URL }}"
},
{
"id": "c42325ba-b870-4296-af68-833df670497d",
"name": "Type",
"type": "string",
"value": "={{ $('Loop Over Items1').item.json.Type }}"
},
{
"id": "6b4ec29b-31da-429b-bd60-89a6c0705c48",
"name": "Description",
"type": "string",
"value": "={{ $('Loop Over Items1').item.json.Description }}"
},
{
"id": "265bd1d6-6a89-42ea-b7da-994715e3806d",
"name": "Email 2",
"type": "string",
"value": "={{ $json.email2 }}"
}
]
}
},
"typeVersion": 3.4
},
{
"id": "27f9e051-ccde-42a0-974d-806de632135a",
"name": "设置用于验证的 URL",
"type": "n8n-nodes-base.set",
"position": [
336,
448
],
"parameters": {
"options": {},
"assignments": {
"assignments": [
{
"id": "f20a894e-3505-404b-a2f8-8648bbed8301",
"name": "URL",
"type": "string",
"value": "={{ $json.URL }}"
}
]
}
},
"typeVersion": 3.4
},
{
"id": "72008dea-4b9c-4b0a-8df0-befb25c64220",
"name": "非重复搜索结果",
"type": "n8n-nodes-base.merge",
"position": [
624,
624
],
"parameters": {
"mode": "combine",
"options": {
"fuzzyCompare": true
},
"joinMode": "keepNonMatches",
"outputDataFrom": "input1",
"fieldsToMatchString": "['URL']"
},
"typeVersion": 3.2
},
{
"id": "a9063fa4-00fa-4279-be72-df006d6a36ea",
"name": "如果网站存在",
"type": "n8n-nodes-base.if",
"position": [
928,
624
],
"parameters": {
"options": {},
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "fc7625cf-225d-4d8e-8dd2-474bd65b6d8d",
"operator": {
"type": "string",
"operation": "exists",
"singleValue": true
},
"leftValue": "={{ $json.URL }}",
"rightValue": ""
}
]
}
},
"typeVersion": 2.2
},
{
"id": "64635b25-9b96-4473-b876-c058ef977593",
"name": "排除文章和博客",
"type": "n8n-nodes-base.if",
"position": [
1280,
624
],
"parameters": {
"options": {
"ignoreCase": false
},
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "or",
"conditions": [
{
"id": "ce6a31cc-e1ac-4786-8300-c3d7553598fe",
"operator": {
"type": "string",
"operation": "notEquals"
},
"leftValue": "={{ $json.Type }}",
"rightValue": "article"
},
{
"id": "89453f8b-f6b7-4c69-bac3-6f10e0a30046",
"operator": {
"name": "filter.operator.equals",
"type": "string",
"operation": "equals"
},
"leftValue": "={{ $json.Type }}",
"rightValue": "blog"
},
{
"id": "e3d4cbe5-549a-4f17-b551-59e18adae86a",
"operator": {
"name": "filter.operator.equals",
"type": "string",
"operation": "equals"
},
"leftValue": "",
"rightValue": ""
}
]
}
},
"typeVersion": 2.2
},
{
"id": "310820f4-5ebe-436d-9069-ead7678c29fd",
"name": "为表格移除重复项",
"type": "n8n-nodes-base.removeDuplicates",
"position": [
1616,
608
],
"parameters": {
"options": {}
},
"typeVersion": 2
},
{
"id": "96c4b66d-f5f4-4026-8ec6-429ab727a10f",
"name": "在表格中添加搜索结果",
"type": "n8n-nodes-base.googleSheets",
"position": [
1888,
608
],
"parameters": {
"columns": {
"value": {
"URL": "={{ $json.URL }}",
"Type": "={{ $json.Type }}",
"Socials": "={{ $json.Social }}",
"Rest Email": "={{ $json[\"Email 2\"] }}",
"Description": "={{ $json.Description }}",
"Search Query": "={{ $('When chat message received').item.json.chatInput }}",
"Business Name": "={{ $json.Name }}",
"Primary Email": "={{ $json.Email1 }}",
"Contact Number": "={{ $json.Phone }}"
},
"schema": [
{
"id": "Search Query",
"type": "string",
"display": true,
"required": false,
"displayName": "Search Query",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "Business Name",
"type": "string",
"display": true,
"required": false,
"displayName": "Business Name",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "Primary Email",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "Primary Email",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "Rest Email",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "Rest Email",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "Contact Number",
"type": "string",
"display": true,
"required": false,
"displayName": "Contact Number",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "URL",
"type": "string",
"display": true,
"required": false,
"displayName": "URL",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "Description",
"type": "string",
"display": true,
"required": false,
"displayName": "Description",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "Type",
"type": "string",
"display": true,
"required": false,
"displayName": "Type",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "Socials",
"type": "string",
"display": true,
"required": false,
"displayName": "Socials",
"defaultMatch": false,
"canBeUsedToMatch": true
}
],
"mappingMode": "defineBelow",
"matchingColumns": [],
"attemptToConvertTypes": false,
"convertFieldsToString": false
},
"options": {},
"operation": "append",
"sheetName": {
"__rl": true,
"mode": "list",
"value": "gid=0",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/1JvDSWt5K1Cc9wCd36MADVbh4tu4KdPAzVlMUstv_ou8/edit#gid=0",
"cachedResultName": "Sheet1"
},
"documentId": {
"__rl": true,
"mode": "list",
"value": "1JvDSWt5K1Cc9wCd36MADVbh4tu4KdPAzVlMUstv_ou8",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/1JvDSWt5K1Cc9wCd36MADVbh4tu4KdPAzVlMUstv_ou8/edit?usp=drivesdk",
"cachedResultName": "Leads Via Google Search"
}
},
"typeVersion": 4.7
},
{
"id": "6fccec45-a3b6-420c-b627-33b15b02cbb4",
"name": "为地图准备查询",
"type": "n8n-nodes-base.code",
"position": [
128,
1120
],
"parameters": {
"jsCode": "const item = items[0];\nconst chatInput = item.json.chatInput;\nconst formattedQuery = chatInput.replaceAll(' ', '+');\n\nreturn [{\n json: {\n \"searchQuery\": formattedQuery\n }\n}];"
},
"typeVersion": 2
},
{
"id": "b4c0a560-6368-47cc-a9b4-284a4072e2e0",
"name": "抓取地图网站",
"type": "n8n-nodes-base.httpRequest",
"onError": "continueRegularOutput",
"position": [
1504,
1120
],
"parameters": {
"url": "={{ $json.website }}",
"options": {
"redirect": {
"redirect": {
"followRedirects": false
}
}
}
},
"typeVersion": 4.2
},
{
"id": "274a3ed6-18fe-47f9-9571-ddd57bdc31c8",
"name": "提取信息",
"type": "n8n-nodes-base.code",
"onError": "continueRegularOutput",
"position": [
1904,
1104
],
"parameters": {
"jsCode": "// --- Safety Check (Guard Clause) ---\nif (!items[0] || !items[0].json || !items[0].json.data) {\n return [{\n json: {\n error: \"Input data from the previous node is missing or in the wrong format.\",\n businessName: null,\n description: null,\n phone: null,\n socials: null,\n email1: null,\n email2: null,\n URL: null\n }\n }];\n}\n\nconst htmlString = items[0].json.data;\n\n// --- Business Name Extraction ---\nlet businessName = \"\";\nconst jsonLdRegex = /<script[^>]*type=[\"']?application\\/ld\\+json[\"']?[^>]*>([\\s\\S]*?)<\\/script>/gi;\nconst jsonLdMatches = [...htmlString.matchAll(jsonLdRegex)];\nfor (const match of jsonLdMatches) {\n try {\n const jsonContent = JSON.parse(match[1]);\n if (!businessName) {\n if (jsonContent.name && (jsonContent['@type'] === 'Dentist' || jsonContent['@type'] === 'Organization')) {\n businessName = jsonContent.name;\n } else if (Array.isArray(jsonContent['@graph'])) {\n for (const item of jsonContent['@graph']) {\n if (item.name && (item['@type'] === 'Dentist' || item['@type'] === 'WebSite')) {\n businessName = item.name.replace(/ New York New York$/, '').trim();\n break;\n }\n }\n }\n }\n } catch (e) { /* Ignore */ }\n}\nif (!businessName) {\n const ogTitleRegex = /<meta[^>]*property=[\"']?og:title[\"']?[^>]*content=[\"']?([^\"'>]*)[\"']?/i;\n const ogTitleMatch = htmlString.match(ogTitleRegex);\n if (ogTitleMatch && ogTitleMatch[1]) {\n businessName = ogTitleMatch[1].split(/[-|]/)[0].trim();\n }\n}\nif (!businessName) {\n const titleRegex = /<title>([\\s\\S]*?)<\\/title>/i;\n const titleMatch = htmlString.match(titleRegex);\n if (titleMatch && titleMatch[1]) {\n businessName = titleMatch[1].split(/[-|]/)[0].trim();\n }\n}\n\n// --- Other Data Extraction ---\nconst descriptionRegex = /<meta[^>]*name=[\"']?description[\"']?[^>]*content=[\"']?([^\"'>]*)[\"']?/i;\nconst descriptionMatch = htmlString.match(descriptionRegex);\nconst description = descriptionMatch ? descriptionMatch[1].trim() : \"\";\n\nconst phoneRegex = /(?:\\+?1[ -]?)?\\(?\\d{3}\\)?[-.\\s]?\\d{3}[-.\\s]?\\d{4}/g;\nconst foundPhones = htmlString.match(phoneRegex) || [];\nconst phoneNumbers = [...new Set(foundPhones)];\n\nfunction findSameAsLinks(obj, links = []) {\n if (obj === null || typeof obj !== 'object') return links;\n if (obj.sameAs && Array.isArray(obj.sameAs)) {\n links.push(...obj.sameAs.filter(item => typeof item === 'string'));\n }\n Object.values(obj).forEach(value => {\n if (typeof value === 'object') findSameAsLinks(value, links);\n });\n return links;\n}\nlet jsonLdLinks = [];\nfor (const match of jsonLdMatches) {\n try {\n const jsonContent = JSON.parse(match[1]);\n findSameAsLinks(jsonContent, jsonLdLinks);\n } catch(e) {/* Ignore */}\n}\nconst socialAnchorRegex = /href=[\"']?(https?:\\/\\/(?:www\\.)?(?:facebook|instagram|twitter|linkedin|yelp|pinterest|plus\\.google)\\.com\\/[^\"'\\s>]+)/gi;\nconst socialAnchorLinks = [...htmlString.matchAll(socialAnchorRegex)].map(match => match[1]);\nconst allSocials = [...jsonLdLinks, ...socialAnchorLinks];\nconst socials = [...new Set(allSocials)];\n\nconst plainTextEmailRegex = /\\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\\.[A-Z]{2,}\\b/gi;\nconst plainTextEmails = htmlString.match(plainTextEmailRegex) || [];\nconst mailtoRegex = /href=[\"']?mailto:([^\"'\\?\\s>]+)/gi;\nconst mailtoEmails = [...htmlString.matchAll(mailtoRegex)].map(match => match[1]);\nconst allEmails = [...plainTextEmails, ...mailtoEmails];\nconst emails = [...new Set(allEmails)];\n\n// --- Final Output Formatting ---\nconst socialString = socials.join(', ');\nconst phoneString = phoneNumbers.join(', ');\n\nconst email1 = emails[0] || null;\nconst email2 = emails[1] || null;\n\n// **UPDATED:** Get the URL and add a trailing slash if needed.\nlet websiteUrl = $('Loop Over Items').first().json.website;\nif (websiteUrl && typeof websiteUrl === 'string' && !websiteUrl.endsWith('/')) {\n websiteUrl += '/';\n}\n\nreturn [{\n json: {\n businessName,\n description,\n phone: phoneString,\n socials: socialString,\n email1,\n email2,\n URL: websiteUrl,\n }\n}];"
},
"typeVersion": 2,
"alwaysOutputData": true
},
{
"id": "1575bc32-cf8f-4409-99ee-268f51feba52",
"name": "设置 URL 验证",
"type": "n8n-nodes-base.set",
"position": [
368,
1760
],
"parameters": {
"options": {},
"assignments": {
"assignments": [
{
"id": "f20a894e-3505-404b-a2f8-8648bbed8301",
"name": "URL",
"type": "string",
"value": "={{ $json.URL }}"
}
]
}
},
"typeVersion": 3.4
},
{
"id": "387ef4ed-617a-4421-900f-05c6e84ff7b1",
"name": "验证唯一结果",
"type": "n8n-nodes-base.merge",
"position": [
672,
1744
],
"parameters": {
"mode": "combine",
"options": {
"fuzzyCompare": true
},
"joinMode": "keepNonMatches",
"outputDataFrom": "input1",
"fieldsToMatchString": "['URL']"
},
"typeVersion": 3.2
},
{
"id": "3e6771bb-fdf6-48ce-a3c5-5e4b49f042fa",
"name": "如果网站存在",
"type": "n8n-nodes-base.if",
"position": [
976,
1744
],
"parameters": {
"options": {},
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "fc7625cf-225d-4d8e-8dd2-474bd65b6d8d",
"operator": {
"type": "string",
"operation": "exists",
"singleValue": true
},
"leftValue": "={{ $json.URL }}",
"rightValue": ""
}
]
}
},
"typeVersion": 2.2
},
{
"id": "e07c2d9a-d9ce-4cc1-9e11-5e502325ac40",
"name": "便签",
"type": "n8n-nodes-base.stickyNote",
"position": [
32,
-656
],
"parameters": {
"color": 3,
"width": 1824,
"height": 704,
"content": "## 阶段 1:Google 自定义搜索分支"
},
"typeVersion": 1
},
{
"id": "e10066d0-7805-46e1-94fc-b1606477adbf",
"name": "便签1",
"type": "n8n-nodes-base.stickyNote",
"position": [
32,
96
],
"parameters": {
"width": 2032,
"height": 704,
"content": "## 阶段 2:Google 地图搜索分支"
},
"typeVersion": 1
},
{
"id": "60c0c125-0be0-4cb6-8a53-eb7c01ecd83a",
"name": "便签2",
"type": "n8n-nodes-base.stickyNote",
"position": [
32,
816
],
"parameters": {
"color": 5,
"width": 2032,
"height": 560,
"content": "## 阶段 3:数据丰富和保存"
},
"typeVersion": 1
},
{
"id": "e9b69fd8-053b-42e7-9b46-108e987b684c",
"name": "便签3",
"type": "n8n-nodes-base.stickyNote",
"position": [
16,
1440
],
"parameters": {
"color": 3,
"width": 1808,
"height": 480,
"content": "## 阶段 4:最终验证和输出"
},
"typeVersion": 1
}
],
"active": false,
"pinData": {},
"settings": {
"executionOrder": "v1"
},
"versionId": "d33f9984-9987-4df7-916f-14b1f42c3e39",
"connections": {
"If": {
"main": [
[
{
"node": "Append row in sheet",
"type": "main",
"index": 0
}
],
[
{
"node": "Loop Over Items1",
"type": "main",
"index": 0
}
]
]
},
"Wait2": {
"main": [
[
{
"node": "Extract Information",
"type": "main",
"index": 0
}
]
]
},
"Extract URLs": {
"main": [
[
{
"node": "Filter Google URLs",
"type": "main",
"index": 0
}
]
]
},
"Scrape Site2": {
"main": [
[
{
"node": "If Site scrapped",
"type": "main",
"index": 0
}
]
]
},
"If Site Exists": {
"main": [
[
{
"node": "Exclude Articles and Blogs",
"type": "main",
"index": 0
}
]
]
},
"If Site exists": {
"main": [
[
{
"node": "Remove Duplicates3",
"type": "main",
"index": 0
}
]
]
},
"Set All Fields": {
"main": [
[
{
"node": "Loop Over Items1",
"type": "main",
"index": 0
}
]
]
},
"Loop Over Items": {
"main": [
[
{
"node": "Validating Unique Results",
"type": "main",
"index": 0
}
],
[
{
"node": "Scrape Map Sites",
"type": "main",
"index": 0
}
]
]
},
"If Site scrapped": {
"main": [
[
{
"node": "Extract Required Fields",
"type": "main",
"index": 0
}
],
[
{
"node": "Loop Over Items1",
"type": "main",
"index": 0
}
]
]
},
"Loop Over Items1": {
"main": [
[
{
"node": "Not Duplicate Search Results",
"type": "main",
"index": 0
}
],
[
{
"node": "Scrape Site2",
"type": "main",
"index": 0
}
]
]
},
"Scrape Map Sites": {
"main": [
[
{
"node": "Wait2",
"type": "main",
"index": 0
}
]
]
},
"Remove Duplicates": {
"main": [
[
{
"node": "Loop Over Items",
"type": "main",
"index": 0
}
]
]
},
"Filter Google URLs": {
"main": [
[
{
"node": "Remove Duplicates",
"type": "main",
"index": 0
}
]
]
},
"Remove Duplicates3": {
"main": [
[
{
"node": "Append row in sheet2",
"type": "main",
"index": 0
}
]
]
},
"Scrape Google Maps": {
"main": [
[
{
"node": "Extract URLs",
"type": "main",
"index": 0
}
]
]
},
"Set URL Validaiton": {
"main": [
[
{
"node": "Validating Unique Results",
"type": "main",
"index": 1
}
]
]
},
"Setting Pagination": {
"main": [
[
{
"node": "Loop for Multiple Page Search",
"type": "main",
"index": 0
}
]
]
},
"Extract Information": {
"main": [
[
{
"node": "Loop Over Items",
"type": "main",
"index": 0
}
]
]
},
"Get row(s) in sheet": {
"main": [
[
{
"node": "Set URL for Validation",
"type": "main",
"index": 0
}
]
]
},
"Flatten Output Items": {
"main": [
[
{
"node": "Information Extraction",
"type": "main",
"index": 0
}
]
]
},
"Get row(s) in sheet1": {
"main": [
[
{
"node": "Set URL Validaiton",
"type": "main",
"index": 0
}
]
]
},
"Information Extraction": {
"main": [
[
{
"node": "Remove Duplicates From Searches",
"type": "main",
"index": 0
}
]
]
},
"Prepare Query for Maps": {
"main": [
[
{
"node": "Scrape Google Maps",
"type": "main",
"index": 0
}
]
]
},
"Set URL for Validation": {
"main": [
[
{
"node": "Not Duplicate Search Results",
"type": "main",
"index": 1
}
]
]
},
"Extract Required Fields": {
"main": [
[
{
"node": "Set All Fields",
"type": "main",
"index": 0
}
]
]
},
"Custom Google Search API": {
"main": [
[
{
"node": "Flatten Output Items",
"type": "main",
"index": 0
}
]
]
},
"Validating Unique Results": {
"main": [
[
{
"node": "If Site exists",
"type": "main",
"index": 0
}
]
]
},
"Exclude Articles and Blogs": {
"main": [
[
{
"node": "Remove Duplicates For Sheets",
"type": "main",
"index": 0
}
]
]
},
"When chat message received": {
"main": [
[
{
"node": "Setting Pagination",
"type": "main",
"index": 0
},
{
"node": "Get row(s) in sheet",
"type": "main",
"index": 0
},
{
"node": "Prepare Query for Maps",
"type": "main",
"index": 0
},
{
"node": "Get row(s) in sheet1",
"type": "main",
"index": 0
}
]
]
},
"Not Duplicate Search Results": {
"main": [
[
{
"node": "If Site Exists",
"type": "main",
"index": 0
}
]
]
},
"Remove Duplicates For Sheets": {
"main": [
[
{
"node": "Add Search Results in Sheets",
"type": "main",
"index": 0
}
]
]
},
"Loop for Multiple Page Search": {
"main": [
[
{
"node": "If",
"type": "main",
"index": 0
}
],
[
{
"node": "Custom Google Search API",
"type": "main",
"index": 0
}
]
]
},
"Remove Duplicates From Searches": {
"main": [
[
{
"node": "Loop for Multiple Page Search",
"type": "main",
"index": 0
}
]
]
}
}
}常见问题
如何使用这个工作流?
复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。
这个工作流适合什么场景?
高级
需要付费吗?
本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。
相关工作流推荐
在可视化参考库中探索n8n节点
在可视化参考库中探索n8n节点
If
Ftp
Set
+93
113 节点I versus AI
其他
使用GPT-4o和Gmail从LinkedIn职位生成个性化冷邮件
使用GPT-4o和Gmail从LinkedIn职位生成个性化冷邮件
If
Set
Code
+12
28 节点Meak
实时 - 使用Gemini和Creatomate自动化病毒式AI视频制作与发布
使用Gemini和Creatomate自动化AI视频创作与多平台发布
Set
Code
Wait
+15
47 节点Intuz
内容创作
使用Apify、Apollo.io和Google Gemini自动化LinkedIn职位AI驱动潜在客户生成
自动化LinkedIn职位潜在客户生成:Apify、Apollo.io和Google Gemini
If
Code
Limit
+11
47 节点Intuz
潜在客户开发
使用LinkedIn职位信号、Apify、Apollo.io和Google Gemini自动化销售拓展
基于LinkedIn职位信号使用Apify和Google Gemini生成个性化销售拓展
If
Code
Limit
+11
47 节点Intuz
AI驱动的谷歌地图商家数据抓取与表格导出
基于AI的谷歌地图商家数据抓取,支持数据丰富化并导出至表格
If
Code
Wait
+13
25 节点Msaid Mohamed el hadi
潜在客户开发
工作流信息
难度等级
高级
节点数量40
分类-
节点类型12
作者
Intuz
@intuzWorkflow automation can help automate your routine activities and help saves $$$, as well as hours of time. As a boutique tech consulting company, Intuz help businesses with custom AI/ML, AI Workflow Automations, and software development. Automate your business workflow for: Sales Marketing Accounting Finance Operations E-Commerce Customer Support Admin & Backoffice Logistics & Supply Chain
外部链接
在 n8n.io 查看 →
分享此工作流