{
  "nodes": [
    {
      "parameters": {
        "path": "scraper",
        "httpMethod": "POST",
        "responseMode": "onReceived"
      },
      "id": "1",
      "name": "Webhook",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 1,
      "position": [
        200,
        250
      ]
    },
    {
      "parameters": {
        "url": "={{ $json[\"body\"][\"search_url\"] }}",
        "responseFormat": "string"
      },
      "id": "2",
      "name": "Get Search Page",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 2,
      "position": [
        450,
        250
      ]
    },
    {
      "parameters": {
        "dataPropertyName": "body",
        "extractions": [
          {
            "name": "name",
            "cssSelector": "h2, .business-name, .result-title"
          },
          {
            "name": "link",
            "cssSelector": "a",
            "attribute": "href"
          }
        ]
      },
      "id": "3",
      "name": "Extract Business Links",
      "type": "n8n-nodes-base.htmlExtract",
      "typeVersion": 1,
      "position": [
        700,
        250
      ]
    },
    {
      "parameters": {
        "mode": "splitInBatches",
        "batchSize": 1
      },
      "id": "4",
      "name": "Split Businesses",
      "type": "n8n-nodes-base.splitInBatches",
      "typeVersion": 1,
      "position": [
        950,
        250
      ]
    },
    {
      "parameters": {
        "url": "={{ $json[\"link\"] }}",
        "responseFormat": "string"
      },
      "id": "5",
      "name": "Visit Business Page",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 2,
      "position": [
        1200,
        250
      ]
    },
    {
      "parameters": {
        "functionCode": "const html = items[0].json;\nconst body = typeof html === 'string' ? html : (html.body || JSON.stringify(html));\n\n// Buscar tel\u00e9fono (regex simple)\nconst phoneRegex = /(\\+?\\d[\\d\\s\\-()]{7,}\\d)/g;\nconst phones = body.match(phoneRegex);\n\nreturn [{\n  json: {\n    name: $json[\"name\"] || \"Sin nombre\",\n    web: $json[\"link\"] || \"\",\n    telefono: phones ? phones[0] : \"No encontrado\"\n  }\n}];"
      },
      "id": "6",
      "name": "Extract Phone",
      "type": "n8n-nodes-base.function",
      "typeVersion": 1,
      "position": [
        1450,
        250
      ]
    },
    {
      "parameters": {
        "operation": "append",
        "binaryData": false,
        "options": {}
      },
      "id": "7",
      "name": "Excel File",
      "type": "n8n-nodes-base.spreadsheetFile",
      "typeVersion": 1,
      "position": [
        1700,
        250
      ]
    }
  ],
  "connections": {
    "Webhook": {
      "main": [
        [
          {
            "node": "Get Search Page",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Search Page": {
      "main": [
        [
          {
            "node": "Extract Business Links",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract Business Links": {
      "main": [
        [
          {
            "node": "Split Businesses",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Split Businesses": {
      "main": [
        [
          {
            "node": "Visit Business Page",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Visit Business Page": {
      "main": [
        [
          {
            "node": "Extract Phone",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract Phone": {
      "main": [
        [
          {
            "node": "Excel File",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}