{
  "version": "1.0.0",
  "exported_at": "2026-06-01T00:00:00.000Z",
  "project": {
    "name": "Empresite Detail Scraper",
    "description": "Scrapes Empresite-elEconomista company detail pages by URL and exports company, CIF, phone, fax, email, web, address, legal form, and activity. This detail-page template uses a multi-URL navigation loop: add additional Empresite detail URLs to navigate.urls[] to scrape multiple companies into one CSV. No on-page pagination was detected on the supplied detail URL. The template waits for both the company metadata marker and the detail-section label 'Razón social' before extracting, reducing the risk of scraping generic directory/redirect pages. Cookie consent is dismissed best-effort; CAPTCHA or blocking may require manual intervention.",
    "color": "bg-[#4589ff]",
    "template_id": "ai-generated"
  },
  "blocks": [
    {
      "block_id": "navigate-1",
      "block_type": "process",
      "title": "Navigate",
      "description": "Go to a URL",
      "position_x": 120,
      "position_y": 220,
      "config": {
        "urls": [
          "https://empresite.eleconomista.es/MERCADO.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": 220,
      "config": {
        "timeout": 30,
        "color": "bg-[#08bdba]"
      }
    },
    {
      "block_id": "inject-javascript-1",
      "block_type": "process",
      "title": "Inject JavaScript",
      "description": "Execute custom JavaScript",
      "position_x": 840,
      "position_y": 220,
      "config": {
        "jsCode": "(()=>{const wanted=['accept','aceptar','agree','ok'];const btns=[...document.querySelectorAll('#didomi-host button,.didomi-components-button,button')];const btn=btns.find(b=>wanted.some(w=>(b.innerText||b.textContent||'').trim().toLowerCase().includes(w)));if(btn){btn.click();return 'clicked_cookie_consent';}return 'no_cookie_consent_button_found';})()",
        "waitForCompletion": true,
        "timeout": 10,
        "color": "bg-[#a56eff]"
      }
    },
    {
      "block_id": "wait-for-element-1",
      "block_type": "process",
      "title": "Wait for Element",
      "description": "Wait until element appears",
      "position_x": 1200,
      "position_y": 220,
      "config": {
        "selector": "meta[property='og:type'][content='company']",
        "timeout": 30,
        "visible": false,
        "color": "bg-[#08bdba]"
      }
    },
    {
      "block_id": "wait-for-text-1",
      "block_type": "process",
      "title": "Wait for Text",
      "description": "Wait until text appears",
      "position_x": 1560,
      "position_y": 220,
      "config": {
        "text": "Razón social",
        "selector": "body",
        "timeout": 30,
        "color": "bg-[#08bdba]"
      }
    },
    {
      "block_id": "structured-export-1",
      "block_type": "process",
      "title": "Structured Export",
      "description": "Export data with custom columns",
      "position_x": 1920,
      "position_y": 220,
      "config": {
        "rowSelector": "html:has(meta[property='og:type'][content='company'])",
        "fileName": "empresite-detalles-de-empresa-scraper.csv",
        "saveLocation": "C:\\Users\\theskd\\Documents\\UScraper\\templates",
        "includeHeaders": true,
        "fileMode": "append",
        "color": "bg-[#42be65]",
        "columns": [
          {
            "name": "empresa",
            "selector": "(()=>{const e=document.querySelector('h1.fn, h1');if(e&&(e.innerText||e.textContent||'').trim())return (e.innerText||e.textContent||'').trim();const og=document.querySelector('meta[property=\"og:title\"],meta[name=\"og:title\"]');if(og&&og.content)return og.content.replace(/\\s+-\\s+CIF.*$/i,'').replace(/\\s*\\|\\s*Empresite.*$/i,'').trim();const title=(document.title||'').replace(/\\s+-\\s+CIF.*$/i,'').replace(/\\s*\\|\\s*Empresite.*$/i,'').trim();return title;})()",
            "attribute": "text",
            "isJs": true
          },
          {
            "name": "cif",
            "selector": "(()=>{const t=(document.body.innerText||'').replace(/\\s+/g,' ').trim();const m=t.match(/CIF\\s+(.+?)\\s+Forma jurídica/i);return m?m[1].trim():'';})()",
            "attribute": "text",
            "isJs": true
          },
          {
            "name": "telefono",
            "selector": "(()=>{const t=(document.body.innerText||'').replace(/\\s+/g,' ').trim();const m=t.match(/Teléfono\\s+(.+?)\\s+(?:FAX|Fax|Web|Email|Acceda|Datos comerciales)/i);let v=m?m[1].trim():'';v=v.replace(/^Llamar\\s*/i,'').trim();return /^Añadir\\b/i.test(v)?'':v;})()",
            "attribute": "text",
            "isJs": true
          },
          {
            "name": "fax",
            "selector": "(()=>{const t=(document.body.innerText||'').replace(/\\s+/g,' ').trim();const m=t.match(/(?:FAX|Fax)\\s+(.+?)\\s+(?:Email|Web|Domicilio|Dirección|Acceda|Datos comerciales)/i);let v=m?m[1].trim():'';return /^Añadir\\b/i.test(v)?'':v;})()",
            "attribute": "text",
            "isJs": true
          },
          {
            "name": "email",
            "selector": "(()=>{const t=(document.body.innerText||'').replace(/\\s+/g,' ').trim();const direct=t.match(/[A-Z0-9._%+-]+@[A-Z0-9.-]+\\.[A-Z]{2,}/i);if(direct)return direct[0];const m=t.match(/Email\\s+(.+?)\\s+(?:Acceda|Datos comerciales|Estructura corporativa)/i);let v=m?m[1].trim():'';return /^Añadir\\b/i.test(v)?'':v;})()",
            "attribute": "text",
            "isJs": true
          },
          {
            "name": "web",
            "selector": "(()=>{const t=(document.body.innerText||'').replace(/\\s+/g,' ').trim();const m=t.match(/Web\\s+(.+?)\\s+Email/i)||t.match(/Sitio web\\s+(.+?)\\s+(?:Cómo llegar|Ver informe|Dirección y contacto|Información General)/i);let v=m?m[1].trim():'';v=v.replace(/^https?:\\/\\//i,'').replace(/^\\/\\//,'').trim();if(!v||/^Añadir\\b/i.test(v)||/^Sitio web$/i.test(v)||/^Web$/i.test(v))return '';const dm=v.match(/(?:www\\.)?[a-z0-9][a-z0-9.-]*\\.[a-z]{2,}(?:\\/[^\\s]*)?/i);return dm?dm[0]:'';})()",
            "attribute": "text",
            "isJs": true
          },
          {
            "name": "domicilio_social",
            "selector": "(()=>{const t=(document.body.innerText||'').replace(/\\s+/g,' ').trim();const m=t.match(/Dirección y contacto\\s+Dirección\\s+(.+?)\\s+(?:Como llegar|VER EN MAPA|Teléfono)/i)||t.match(/Domicilio social\\s+(.+?)\\s+(?:Forma jurídica|Actividad|Teléfono|FAX|Email|Web)/i);return m?m[1].trim():'';})()",
            "attribute": "text",
            "isJs": true
          },
          {
            "name": "forma_juridica",
            "selector": "(()=>{const t=(document.body.innerText||'').replace(/\\s+/g,' ').trim();const m=t.match(/Forma jurídica\\s+(.+?)\\s+Sector/i);return m?m[1].trim():'';})()",
            "attribute": "text",
            "isJs": true
          },
          {
            "name": "actividad",
            "selector": "(()=>{const t=(document.body.innerText||'').replace(/\\s+/g,' ').trim();const m=t.match(/Actividad\\s+(.+?)\\s+Actividad CNAE/i);return m?m[1].trim():'';})()",
            "attribute": "text",
            "isJs": true
          }
        ]
      }
    },
    {
      "block_id": "loop-continue-1",
      "block_type": "process",
      "title": "Loop Continue",
      "description": "Continue multi-input loop",
      "position_x": 2280,
      "position_y": 220,
      "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": "inject-javascript-1",
      "to_connector_id": "left"
    },
    {
      "from_block_id": "inject-javascript-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": "wait-for-text-1",
      "to_connector_id": "left"
    },
    {
      "from_block_id": "wait-for-text-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": 116,
      "width": 1760,
      "height": 296,
      "z_index": 20,
      "data": {
        "memberBlockIds": [
          "navigate-1",
          "wait-for-page-load-1",
          "wait-for-element-1",
          "wait-for-text-1"
        ]
      }
    },
    {
      "id": "group-interaction",
      "element_type": "group",
      "title": "Interaction",
      "color": "#a56eff",
      "position_x": 768,
      "position_y": 116,
      "width": 380,
      "height": 296,
      "z_index": 20,
      "data": {
        "memberBlockIds": [
          "inject-javascript-1"
        ]
      }
    },
    {
      "id": "group-extract",
      "element_type": "group",
      "title": "Data Extraction",
      "color": "#42be65",
      "position_x": 1848,
      "position_y": 116,
      "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": 2208,
      "position_y": 116,
      "width": 380,
      "height": 296,
      "z_index": 20,
      "data": {
        "memberBlockIds": [
          "loop-continue-1"
        ]
      }
    },
    {
      "id": "note-overview",
      "element_type": "note",
      "title": "Overview",
      "content": "Scrapes Empresite-elEconomista company detail pages by URL and exports company, CIF, phone, fax, email, web, address, legal form, and activity. This detail-page template uses a multi-URL navigation loop: add additional Empresite detail URLs to navigate.urls[] to scrape multiple companies into one CSV. No on-page pagination was detected on the supplied detail URL. The template waits for both the company metadata marker and the detail-section label 'Razón social' before extracting, reducing the risk of scraping generic directory/redirect pages. Cookie consent is dismissed best-effort; CAPTCHA or blocking may require manual intervention.",
      "color": "#f1c21b",
      "position_x": 80,
      "position_y": 20,
      "width": 480,
      "height": 160,
      "z_index": 22,
      "data": {}
    },
    {
      "id": "note-block-inject-javascript-1",
      "element_type": "note",
      "title": "Note: Inject JavaScript",
      "content": "Runs custom JavaScript in the page: `(()=>{const wanted=['accept','aceptar','agree','ok'];const btns=[...document.querySelectorAll('#dido...` Verify in browser if results are empty.",
      "color": "#ee5396",
      "position_x": 1040,
      "position_y": 200,
      "width": 340,
      "height": 140,
      "z_index": 22,
      "data": {
        "block_id": "inject-javascript-1"
      }
    },
    {
      "id": "note-block-structured-export-1",
      "element_type": "note",
      "title": "Note: Structured Export",
      "content": "Structured export with JS columns (empresa, cif, telefono, fax, email). These selectors are fragile — update if the site layout changes.",
      "color": "#ee5396",
      "position_x": 2120,
      "position_y": 200,
      "width": 340,
      "height": 125,
      "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": 2480,
      "position_y": 200,
      "width": 340,
      "height": 123,
      "z_index": 22,
      "data": {
        "block_id": "loop-continue-1"
      }
    }
  ]
}