{
  "version": "1.0.0",
  "exported_at": "2026-06-01T05:15:00.000Z",
  "project": {
    "name": "Yellow Pages Spain ScraperProduct Details",
    "description": "Scrapes Páginas Amarillas Spain business detail pages by URL and exports nombre, pagina_url, categoria, telefono, ubicacion, horario, informacion_y_servicio, actividades, descripcion, sitio_web, and hora_actual. Navigation strategy: known detail URL list using navigate.urls[] plus loop-continue, appending all detail-page records into one CSV. Add more paginasamarillas.es/f/... detail URLs to the urls array before running.",
    "color": "bg-[#f1c21b]",
    "template_id": "ai-generated"
  },
  "blocks": [
    {
      "block_id": "navigate-1",
      "block_type": "process",
      "title": "Navigate",
      "description": "Go to a URL",
      "position_x": 120,
      "position_y": 240,
      "config": {
        "urls": [
          "https://www.paginasamarillas.es/f/madrid/legalitas_195760715_000000073.html",
          "https://www.paginasamarillas.es/f/madrid/bufete-c-c-abogados_196778807_000000001.html"
        ],
        "color": "bg-[#4589ff]"
      }
    },
    {
      "block_id": "wait-for-page-load-1",
      "block_type": "process",
      "title": "Wait for Page Load",
      "description": "Wait for page to finish loading",
      "position_x": 480,
      "position_y": 240,
      "config": {
        "timeout": 30,
        "color": "bg-[#08bdba]"
      }
    },
    {
      "block_id": "wait-for-element-1",
      "block_type": "process",
      "title": "Wait for Element",
      "description": "Wait until element appears",
      "position_x": 840,
      "position_y": 240,
      "config": {
        "selector": "h1",
        "timeout": 30,
        "visible": true,
        "color": "bg-[#08bdba]"
      }
    },
    {
      "block_id": "structured-export-1",
      "block_type": "process",
      "title": "Structured Export",
      "description": "Export data with custom columns",
      "position_x": 1200,
      "position_y": 240,
      "config": {
        "rowSelector": "body",
        "fileName": "paginas-amarillas-detalles-scraper.csv",
        "saveLocation": "C:\\Users\\theskd\\Documents\\UScraper\\templates",
        "includeHeaders": true,
        "fileMode": "append",
        "color": "bg-[#42be65]",
        "columns": [
          {
            "name": "nombre",
            "selector": "(() => (ROW.querySelector('h1')?.textContent || '').trim())()",
            "attribute": "text",
            "isJs": true
          },
          {
            "name": "pagina_url",
            "selector": "(() => window.location.href.split('#')[0])()",
            "attribute": "text",
            "isJs": true
          },
          {
            "name": "categoria",
            "selector": "(() => { const h1=(ROW.querySelector('h1')?.textContent||'').trim(); const lines=(ROW.innerText||'').split('\\n').map(s=>s.trim()).filter(Boolean); const i=lines.indexOf(h1); const after=i>=0?lines.slice(i+1,i+8):lines; const cat=after.find(s=>/\\ben\\b/i.test(s)&&!/^Contactar$/i.test(s)&&!s.startsWith('http')); if(cat) return cat; const crumbs=Array.from(ROW.querySelectorAll('a[href*=\"/a/\"]')).map(a=>a.textContent.trim()).filter(Boolean); return crumbs[crumbs.length-1]||''; })()",
            "attribute": "text",
            "isJs": true
          },
          {
            "name": "telefono",
            "selector": "(() => { const a=ROW.querySelector('a[href^=\"tel:\"]'); return a ? a.getAttribute('href').replace(/^tel:/,'').trim() : ''; })()",
            "attribute": "text",
            "isJs": true
          },
          {
            "name": "ubicacion",
            "selector": "(() => { const sel=ROW.querySelector('[itemprop=\"address\"], [class*=\"direccion\" i], [class*=\"address\" i]'); if(sel) return sel.textContent.trim().replace(/\\s+/g,' '); const phone=(ROW.querySelector('a[href^=\"tel:\"]')?.getAttribute('href')||'').replace(/^tel:/,'').replace(/^\\+34/,''); const lines=(ROW.innerText||'').split('\\n').map(s=>s.trim()).filter(Boolean); const idx=lines.findIndex(s=>s.replace(/\\s+/g,'').includes(phone)); const loc=lines.slice(idx+1, idx+8).find(s=>/\\d{5}/.test(s) || /(Calle|Avenida|Paseo|Vía|Via|Plaza|Carretera|Camino)/i.test(s)); return loc||''; })()",
            "attribute": "text",
            "isJs": true
          },
          {
            "name": "horario",
            "selector": "(() => { const text=(ROW.innerText||'').replace(/\\s+/g,' '); const m=text.match(/Lunes\\s+.*?(?:Domingo\\s+(?:Cerrado|\\d{1,2}:\\d{2}[^A-Z]*))/i); return m ? m[0].trim() : ''; })()",
            "attribute": "text",
            "isJs": true
          },
          {
            "name": "informacion_y_servicio",
            "selector": "(() => { const lines=(ROW.innerText||'').split('\\n').map(s=>s.trim()).filter(Boolean); const start=lines.findIndex(s=>s.startsWith('Información y servicios')); if(start<0) return ''; const end=lines.findIndex((s,i)=>i>start && (s==='Actividades' || s.startsWith('Acerca de') || s.startsWith('Ver condiciones'))); return lines.slice(start+1, end>start?end:start+5).join(' ').trim(); })()",
            "attribute": "text",
            "isJs": true
          },
          {
            "name": "actividades",
            "selector": "(() => { const lines=(ROW.innerText||'').split('\\n').map(s=>s.trim()).filter(Boolean); const start=lines.findIndex(s=>s==='Actividades'); if(start<0) return ''; const next=lines.slice(start+1).find(s=>!s.startsWith('Acerca de') && !s.startsWith('Ver condiciones') && !s.startsWith('Conversación')); return next||''; })()",
            "attribute": "text",
            "isJs": true
          },
          {
            "name": "descripcion",
            "selector": "(() => { const lines=(ROW.innerText||'').split('\\n').map(s=>s.trim()).filter(Boolean); const start=lines.findIndex(s=>s.startsWith('Acerca de')); if(start<0) return ''; const end=lines.findIndex((s,i)=>i>start && (s.startsWith('Actividades relacionadas') || s.startsWith('Ver condiciones') || s.startsWith('Conversación') || s.startsWith('¿Cómo llegar?'))); return lines.slice(start+1, end>start?end:lines.length).join(' ').trim(); })()",
            "attribute": "text",
            "isJs": true
          },
          {
            "name": "sitio_web",
            "selector": "(() => { const a=ROW.querySelector('a.sitio-web[href]'); return a ? a.href : ''; })()",
            "attribute": "text",
            "isJs": true
          },
          {
            "name": "hora_actual",
            "selector": "(() => new Date().toISOString())()",
            "attribute": "text",
            "isJs": true
          }
        ]
      }
    },
    {
      "block_id": "loop-continue-1",
      "block_type": "process",
      "title": "Loop Continue",
      "description": "Continue multi-input loop",
      "position_x": 1560,
      "position_y": 240,
      "config": {
        "color": "bg-[#8d8d8d]"
      }
    }
  ],
  "connections": [
    {
      "from_block_id": "navigate-1",
      "from_connector_id": "right",
      "to_block_id": "wait-for-page-load-1",
      "to_connector_id": "left"
    },
    {
      "from_block_id": "wait-for-page-load-1",
      "from_connector_id": "right",
      "to_block_id": "wait-for-element-1",
      "to_connector_id": "left"
    },
    {
      "from_block_id": "wait-for-element-1",
      "from_connector_id": "right",
      "to_block_id": "structured-export-1",
      "to_connector_id": "left"
    },
    {
      "from_block_id": "structured-export-1",
      "from_connector_id": "right",
      "to_block_id": "loop-continue-1",
      "to_connector_id": "left"
    }
  ],
  "canvas_elements": [
    {
      "id": "group-load",
      "element_type": "group",
      "title": "Page Load",
      "color": "#08bdba",
      "position_x": 48,
      "position_y": 136,
      "width": 1040,
      "height": 296,
      "z_index": 20,
      "data": {
        "memberBlockIds": [
          "navigate-1",
          "wait-for-page-load-1",
          "wait-for-element-1"
        ]
      }
    },
    {
      "id": "group-extract",
      "element_type": "group",
      "title": "Data Extraction",
      "color": "#42be65",
      "position_x": 1128,
      "position_y": 136,
      "width": 380,
      "height": 296,
      "z_index": 20,
      "data": {
        "memberBlockIds": [
          "structured-export-1"
        ]
      }
    },
    {
      "id": "group-pagination",
      "element_type": "group",
      "title": "Pagination Loop",
      "color": "#ff832b",
      "position_x": 1488,
      "position_y": 136,
      "width": 380,
      "height": 296,
      "z_index": 20,
      "data": {
        "memberBlockIds": [
          "loop-continue-1"
        ]
      }
    },
    {
      "id": "note-overview",
      "element_type": "note",
      "title": "Overview",
      "content": "Scrapes Páginas Amarillas Spain business detail pages by URL and exports nombre, pagina_url, categoria, telefono, ubicacion, horario, informacion_y_servicio, actividades, descripcion, sitio_web, and hora_actual. Navigation strategy: known detail URL list using navigate.urls[] plus loop-continue, appending all detail-page records into one CSV. Add more paginasamarillas.es/f/... detail URLs to the urls array before running.",
      "color": "#f1c21b",
      "position_x": 80,
      "position_y": 20,
      "width": 480,
      "height": 160,
      "z_index": 22,
      "data": {}
    },
    {
      "id": "note-block-navigate-1",
      "element_type": "note",
      "title": "Note: Navigate",
      "content": "Multi-URL loop over 2 pages. Pair with loop-continue at the end of each iteration.",
      "color": "#ee5396",
      "position_x": 320,
      "position_y": 220,
      "width": 328,
      "height": 107,
      "z_index": 22,
      "data": {
        "block_id": "navigate-1"
      }
    },
    {
      "id": "note-block-structured-export-1",
      "element_type": "note",
      "title": "Note: Structured Export",
      "content": "Structured export with JS columns (nombre, pagina_url, categoria, telefono, ubicacion). These selectors are fragile — update if the site layout changes.",
      "color": "#ee5396",
      "position_x": 1400,
      "position_y": 220,
      "width": 340,
      "height": 130,
      "z_index": 22,
      "data": {
        "block_id": "structured-export-1"
      }
    },
    {
      "id": "note-block-loop-continue-1",
      "element_type": "note",
      "title": "Note: Loop Continue",
      "content": "Loop Continue advances a multi-URL or multi-text loop. Place at the end of the loop body with a clear back-edge to the loop start.",
      "color": "#ee5396",
      "position_x": 1760,
      "position_y": 220,
      "width": 340,
      "height": 123,
      "z_index": 22,
      "data": {
        "block_id": "loop-continue-1"
      }
    }
  ]
}