{
  "name": "Scraper Pages Jaunes (Apify) \u2192 Google Sheets",
  "nodes": [
    {
      "parameters": {},
      "id": "trigger",
      "name": "Lancer le scraping",
      "type": "n8n-nodes-base.manualTrigger",
      "typeVersion": 1,
      "position": [
        220,
        300
      ]
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "quoi",
              "name": "quoi",
              "value": "plombier",
              "type": "string"
            },
            {
              "id": "ou",
              "name": "ou",
              "value": "paris",
              "type": "string"
            },
            {
              "id": "max_results",
              "name": "max_results",
              "value": 100,
              "type": "number"
            }
          ]
        },
        "options": {}
      },
      "id": "set-params",
      "name": "Parametres de recherche",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.3,
      "position": [
        440,
        300
      ],
      "notes": "Modifie ici : quoi = metier/activite, ou = ville. Exemples : 'dentiste' + 'lyon', 'restaurant italien' + 'bordeaux', 'agence immobiliere' + 'marseille'"
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://api.apify.com/v2/acts/saswave~pagesjaunes-scraper/runs",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpQueryAuth",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\n  \"query\": \"{{ $json.quoi }}\",\n  \"location\": \"{{ $json.ou }}\",\n  \"maxItems\": {{ $json.max_results }}\n}",
        "options": {}
      },
      "id": "apify-start",
      "name": "Lancer Apify PagesJaunes",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.1,
      "position": [
        660,
        300
      ],
      "credentials": {
        "httpQueryAuth": {
          "name": "<your credential>"
        }
      },
      "notes": "Utilise l'acteur dedie saswave/pagesjaunes-scraper. $1.50 pour 1000 resultats."
    },
    {
      "parameters": {
        "amount": 30,
        "unit": "seconds"
      },
      "id": "wait-1",
      "name": "Attendre 30s",
      "type": "n8n-nodes-base.wait",
      "typeVersion": 1.1,
      "position": [
        880,
        300
      ]
    },
    {
      "parameters": {
        "method": "GET",
        "url": "=https://api.apify.com/v2/actor-runs/{{ $('Lancer Apify PagesJaunes').item.json.data.id }}",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpQueryAuth",
        "options": {}
      },
      "id": "check-status",
      "name": "Verifier statut",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.1,
      "position": [
        1100,
        300
      ],
      "credentials": {
        "httpQueryAuth": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict"
          },
          "conditions": [
            {
              "id": "condition-done",
              "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": [
        1320,
        300
      ]
    },
    {
      "parameters": {
        "method": "GET",
        "url": "=https://api.apify.com/v2/datasets/{{ $('Lancer Apify PagesJaunes').item.json.data.defaultDatasetId }}/items",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpQueryAuth",
        "options": {
          "response": {
            "response": {
              "responseFormat": "json"
            }
          }
        }
      },
      "id": "get-results",
      "name": "Recuperer les entreprises",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.1,
      "position": [
        1540,
        200
      ],
      "credentials": {
        "httpQueryAuth": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "amount": 20,
        "unit": "seconds"
      },
      "id": "wait-more",
      "name": "Attendre encore",
      "type": "n8n-nodes-base.wait",
      "typeVersion": 1.1,
      "position": [
        1540,
        400
      ]
    },
    {
      "parameters": {
        "operation": "append",
        "documentId": {
          "__rl": true,
          "value": "VOTRE_SPREADSHEET_ID",
          "mode": "id"
        },
        "sheetName": {
          "__rl": true,
          "value": "Leads PJ",
          "mode": "name"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "Nom": "={{ $json.name }}",
            "Telephone": "={{ $json.phoneNumber }}",
            "Email": "={{ $json.email }}",
            "Adresse": "={{ $json.address }}",
            "Ville": "={{ $json.city }}",
            "SIRET": "={{ $json.siret }}",
            "Code NAF": "={{ $json.naf }}",
            "Date Creation": "={{ $json.creationDate }}",
            "Categorie": "={{ $json.category }}",
            "Site Web": "={{ $json.website }}",
            "URL Pages Jaunes": "={{ $json.url }}"
          }
        },
        "options": {}
      },
      "id": "google-sheets",
      "name": "Sauvegarder dans Sheets",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.3,
      "position": [
        1760,
        200
      ],
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      }
    }
  ],
  "connections": {
    "Lancer le scraping": {
      "main": [
        [
          {
            "node": "Parametres de recherche",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Parametres de recherche": {
      "main": [
        [
          {
            "node": "Lancer Apify PagesJaunes",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Lancer Apify PagesJaunes": {
      "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 les entreprises",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Attendre encore",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Attendre encore": {
      "main": [
        [
          {
            "node": "Verifier statut",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Recuperer les entreprises": {
      "main": [
        [
          {
            "node": "Sauvegarder dans Sheets",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1"
  },
  "staticData": null,
  "meta": {
    "templateCredsSetupCompleted": false
  },
  "versionId": "2",
  "triggerCount": 0,
  "tags": [
    {
      "name": "scraping"
    },
    {
      "name": "pages-jaunes"
    },
    {
      "name": "apify"
    },
    {
      "name": "prospection"
    }
  ]
}