{
  "name": "Google Maps Scraper (Apify) \u2192 Google Sheets",
  "nodes": [
    {
      "parameters": {},
      "id": "trigger",
      "name": "Lancer le scraping",
      "type": "n8n-nodes-base.manualTrigger",
      "typeVersion": 1,
      "position": [
        240,
        300
      ]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://api.apify.com/v2/acts/compass~crawler-google-places/runs",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpQueryAuth",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\n  \"searchStringsArray\": [\"{{ $json.search_query }}\"],\n  \"locationQuery\": \"{{ $json.location }}\",\n  \"maxCrawledPlacesPerSearch\": {{ $json.max_results || 50 }},\n  \"language\": \"fr\",\n  \"exportPlaceUrls\": false,\n  \"includeWebResults\": false,\n  \"includeHistogram\": false,\n  \"includeOpeningHours\": true,\n  \"includePeopleAlsoSearch\": false,\n  \"additionalInfo\": true,\n  \"reviewsSort\": \"newest\",\n  \"scrapeDirectories\": false\n}",
        "options": {}
      },
      "id": "apify-start",
      "name": "Lancer Apify Scraper",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.1,
      "position": [
        460,
        300
      ],
      "credentials": {
        "httpQueryAuth": {
          "name": "<your credential>"
        }
      },
      "notes": "Lance le scraper Google Maps sur Apify. Remplace VOTRE_CREDENTIAL_ID par ton credential."
    },
    {
      "parameters": {
        "amount": 30,
        "unit": "seconds"
      },
      "id": "wait-1",
      "name": "Attendre 30s",
      "type": "n8n-nodes-base.wait",
      "typeVersion": 1.1,
      "position": [
        680,
        300
      ]
    },
    {
      "parameters": {
        "method": "GET",
        "url": "=https://api.apify.com/v2/actor-runs/{{ $('Lancer Apify Scraper').item.json.data.id }}",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpQueryAuth",
        "options": {}
      },
      "id": "check-status",
      "name": "Verifier statut",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.1,
      "position": [
        900,
        300
      ],
      "credentials": {
        "httpQueryAuth": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict"
          },
          "conditions": [
            {
              "id": "condition-running",
              "leftValue": "={{ $json.data.status }}",
              "rightValue": "SUCCEEDED",
              "operator": {
                "type": "string",
                "operation": "equals"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "id": "if-finished",
      "name": "Scraping termine?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2,
      "position": [
        1120,
        300
      ]
    },
    {
      "parameters": {
        "method": "GET",
        "url": "=https://api.apify.com/v2/datasets/{{ $('Lancer Apify Scraper').item.json.data.defaultDatasetId }}/items",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpQueryAuth",
        "options": {
          "response": {
            "response": {
              "responseFormat": "json"
            }
          }
        }
      },
      "id": "get-results",
      "name": "Recuperer resultats",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.1,
      "position": [
        1340,
        200
      ],
      "credentials": {
        "httpQueryAuth": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "amount": 15,
        "unit": "seconds"
      },
      "id": "wait-more",
      "name": "Attendre encore",
      "type": "n8n-nodes-base.wait",
      "typeVersion": 1.1,
      "position": [
        1340,
        400
      ]
    },
    {
      "parameters": {
        "operation": "append",
        "documentId": {
          "__rl": true,
          "value": "VOTRE_SPREADSHEET_ID",
          "mode": "id"
        },
        "sheetName": {
          "__rl": true,
          "value": "Leads",
          "mode": "name"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "Nom": "={{ $json.title }}",
            "Adresse": "={{ $json.address }}",
            "Telephone": "={{ $json.phone }}",
            "Site Web": "={{ $json.website }}",
            "Note": "={{ $json.totalScore }}",
            "Nb Avis": "={{ $json.reviewsCount }}",
            "Categories": "={{ $json.categories ? $json.categories.join(', ') : '' }}",
            "Horaires": "={{ $json.openingHours ? JSON.stringify($json.openingHours) : '' }}",
            "URL Google Maps": "={{ $json.url }}",
            "Latitude": "={{ $json.location?.lat }}",
            "Longitude": "={{ $json.location?.lng }}"
          }
        },
        "options": {}
      },
      "id": "google-sheets",
      "name": "Sauvegarder dans Sheets",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.3,
      "position": [
        1560,
        200
      ],
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "search_query",
              "name": "search_query",
              "value": "restaurant",
              "type": "string"
            },
            {
              "id": "location",
              "name": "location",
              "value": "Paris, France",
              "type": "string"
            },
            {
              "id": "max_results",
              "name": "max_results",
              "value": 50,
              "type": "number"
            }
          ]
        },
        "options": {}
      },
      "id": "set-params",
      "name": "Parametres de recherche",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.3,
      "position": [
        240,
        300
      ],
      "notes": "Modifie ici: search_query (ex: 'plombier', 'restaurant italien'), location (ex: 'Lyon, France'), max_results (ex: 100)"
    }
  ],
  "connections": {
    "Lancer le scraping": {
      "main": [
        [
          {
            "node": "Parametres de recherche",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Parametres de recherche": {
      "main": [
        [
          {
            "node": "Lancer Apify Scraper",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Lancer Apify Scraper": {
      "main": [
        [
          {
            "node": "Attendre 30s",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Attendre 30s": {
      "main": [
        [
          {
            "node": "Verifier statut",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Verifier statut": {
      "main": [
        [
          {
            "node": "Scraping termine?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Scraping termine?": {
      "main": [
        [
          {
            "node": "Recuperer resultats",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Attendre encore",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Attendre encore": {
      "main": [
        [
          {
            "node": "Verifier statut",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Recuperer resultats": {
      "main": [
        [
          {
            "node": "Sauvegarder dans Sheets",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1"
  },
  "staticData": null,
  "meta": {
    "templateCredsSetupCompleted": false
  },
  "versionId": "1",
  "triggerCount": 0,
  "tags": [
    {
      "name": "scraping"
    },
    {
      "name": "google-maps"
    },
    {
      "name": "apify"
    }
  ]
}