{
  "name": "Google Maps Lead Scraper",
  "nodes": [
    {
      "parameters": {},
      "type": "n8n-nodes-base.manualTrigger",
      "typeVersion": 1,
      "position": [
        0,
        0
      ],
      "id": "4a6f9faa-5b11-41fe-88c9-cc8a262a2de2",
      "name": "Start Scraping"
    },
    {
      "parameters": {
        "options": {}
      },
      "type": "n8n-nodes-base.removeDuplicates",
      "typeVersion": 2,
      "position": [
        720,
        0
      ],
      "id": "47d741e7-a53f-40c7-bf7c-09a446b0d229",
      "name": "Remove Duplicate URLs"
    },
    {
      "parameters": {
        "options": {}
      },
      "type": "n8n-nodes-base.splitInBatches",
      "typeVersion": 3,
      "position": [
        1080,
        0
      ],
      "id": "6cd049c8-425e-45e0-8d45-6a4883c2f496",
      "name": "Loop Over Websites"
    },
    {
      "parameters": {
        "amount": 1
      },
      "type": "n8n-nodes-base.wait",
      "typeVersion": 1.1,
      "position": [
        1460,
        180
      ],
      "id": "3c3a3870-034d-4147-936a-4b0f19b7727d",
      "name": "Rate Limit Delay"
    },
    {
      "parameters": {
        "maxItems": 10
      },
      "type": "n8n-nodes-base.limit",
      "typeVersion": 1,
      "position": [
        900,
        0
      ],
      "id": "a377879d-517d-4c90-a3d4-a7a0c190787e",
      "name": "Limit Websites"
    },
    {
      "parameters": {},
      "type": "n8n-nodes-base.wait",
      "typeVersion": 1.1,
      "position": [
        1280,
        -180
      ],
      "id": "5f4ae91a-29c7-4fb3-b535-34bc5194b183",
      "name": "Collect Results"
    },
    {
      "parameters": {
        "fieldToSplitOut": "emails",
        "options": {}
      },
      "type": "n8n-nodes-base.splitOut",
      "typeVersion": 1,
      "position": [
        1640,
        -180
      ],
      "id": "645bf31c-4b3c-4f4c-b90b-610fc2d6007c",
      "name": "Split Emails"
    },
    {
      "parameters": {
        "jsCode": "const input = $input.first().json.data\nconst regex = /[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.(?!jpeg|jpg|png|gif|webp|svg)[a-zA-Z]{2,}/g\nconst emails = input.match(regex)\nreturn {json: {emails:emails}}"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        1640,
        180
      ],
      "id": "7e9c227c-2321-429a-a3f3-4c3a77bc6cf3",
      "name": "Extract Emails",
      "alwaysOutputData": true,
      "onError": "continueRegularOutput"
    },
    {
      "parameters": {
        "jsCode": "const input = $input.first().json.data\nconst regex = /https?:\\/\\/[^\\/\\s\"'>]+/g\nconst websites = input.match(regex)\nreturn websites.map(website => ({json:{website}}))"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        360,
        0
      ],
      "id": "fb76c70c-385d-4e7f-93cd-43023690076a",
      "name": "Extract Website URLs"
    },
    {
      "parameters": {
        "url": "https://www.google.com/maps/search/calgary+dentists",
        "options": {
          "allowUnauthorizedCerts": true,
          "response": {
            "response": {
              "fullResponse": true
            }
          }
        }
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        180,
        0
      ],
      "id": "b10c0ed6-5a94-4272-b65c-bd19bd674fa0",
      "name": "Search Google Maps"
    },
    {
      "parameters": {
        "url": "={{ $json.website }}",
        "options": {
          "redirect": {
            "redirect": {
              "followRedirects": false
            }
          }
        }
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        1280,
        180
      ],
      "id": "58a0d85d-f6eb-47d1-ba9c-3af69ddd30fb",
      "name": "Scrape Website",
      "onError": "continueRegularOutput"
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "a6786c58-424a-409a-b87f-8a7592cb7944",
              "leftValue": "={{ $json.emails }}",
              "rightValue": "",
              "operator": {
                "type": "array",
                "operation": "exists",
                "singleValue": true
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.filter",
      "typeVersion": 2.2,
      "position": [
        1460,
        -180
      ],
      "id": "4618e775-d14d-4355-b3a2-cd6a6bbc70e8",
      "name": "Filter Empty Results"
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "bf0a5053-9660-457c-9581-964793bb6d7d",
              "leftValue": "={{ $json.website }}",
              "rightValue": "schema",
              "operator": {
                "type": "string",
                "operation": "notContains"
              }
            },
            {
              "id": "9110b9e0-12aa-45cc-bde0-9eda8c10970e",
              "leftValue": "={{ $json.website }}",
              "rightValue": "google",
              "operator": {
                "type": "string",
                "operation": "notContains"
              }
            },
            {
              "id": "fb9b6ed6-96a5-4560-ab10-b8a4b9a61a2b",
              "leftValue": "={{ $json.website }}",
              "rightValue": "gg",
              "operator": {
                "type": "string",
                "operation": "notContains"
              }
            },
            {
              "id": "10500c0b-cdbd-4816-aba3-df60d69845dc",
              "leftValue": "={{ $json.website }}",
              "rightValue": "gstatic",
              "operator": {
                "type": "string",
                "operation": "notContains"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.filter",
      "typeVersion": 2.2,
      "position": [
        540,
        0
      ],
      "id": "74513e7e-a7dc-4b19-b23e-01efd82c9d6d",
      "name": "Remove Google Links"
    },
    {
      "parameters": {
        "options": {}
      },
      "type": "n8n-nodes-base.removeDuplicates",
      "typeVersion": 2,
      "position": [
        1820,
        -180
      ],
      "id": "035fbbe8-7758-4c7b-be8e-c1cba8fc48bc",
      "name": "Remove Duplicate Emails"
    },
    {
      "parameters": {
        "operation": "append",
        "documentId": {
          "__rl": true,
          "value": "YOUR_SHEET_ID",
          "mode": "list",
          "cachedResultName": "Scrape WITHOUT Paying for APIs",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/YOUR_SHEET_ID/edit?usp=drivesdk"
        },
        "sheetName": {
          "__rl": true,
          "value": "gid=0",
          "mode": "list",
          "cachedResultName": "emails",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/YOUR_SHEET_ID/edit#gid=0"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "emails": "={{ $json.emails }}"
          },
          "matchingColumns": [
            "emails"
          ],
          "schema": [
            {
              "id": "emails",
              "displayName": "emails",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            }
          ]
        },
        "options": {
          "useAppend": true
        }
      },
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.5,
      "position": [
        2000,
        -180
      ],
      "id": "aa3e9285-235d-4fda-ab0e-45134cf825dd",
      "name": "Save to Google Sheets"
    }
  ],
  "connections": {
    "Start Scraping": {
      "main": [
        [
          {
            "node": "Search Google Maps",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Remove Duplicate URLs": {
      "main": [
        [
          {
            "node": "Limit Websites",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop Over Websites": {
      "main": [
        [
          {
            "node": "Collect Results",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Scrape Website",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Rate Limit Delay": {
      "main": [
        [
          {
            "node": "Extract Emails",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Limit Websites": {
      "main": [
        [
          {
            "node": "Loop Over Websites",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Collect Results": {
      "main": [
        [
          {
            "node": "Filter Empty Results",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Split Emails": {
      "main": [
        [
          {
            "node": "Remove Duplicate Emails",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract Emails": {
      "main": [
        [
          {
            "node": "Loop Over Websites",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract Website URLs": {
      "main": [
        [
          {
            "node": "Remove Google Links",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Search Google Maps": {
      "main": [
        [
          {
            "node": "Extract Website URLs",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Scrape Website": {
      "main": [
        [
          {
            "node": "Rate Limit Delay",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Filter Empty Results": {
      "main": [
        [
          {
            "node": "Split Emails",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Remove Google Links": {
      "main": [
        [
          {
            "node": "Remove Duplicate URLs",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Remove Duplicate Emails": {
      "main": [
        [
          {
            "node": "Save to Google Sheets",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1"
  },
  "pinData": {}
}