{
  "version": "1.0.0",
  "exported_at": "2026-06-03T03:30:00.000Z",
  "project": {
    "name": "AutoScout24 Spain Scraper",
    "description": "Extracts AutoScout24 Spain car listing data equivalent to the Octoparse template: marca, modelo, listing URL, description/features, price, price level, mileage, transmission/inferred gearbox, year, fuel, power, dealer, dealer address, and image URL. Default start URL is an AutoScout24 Spain search-results page and can be edited to any AutoScout24.es /lst search URL. Pagination uses the Spanish 'Siguiente' next-page control and appends each results page to one CSV. To avoid UScraper's 1000-iteration safety limit on very large AutoScout24 searches, this template includes a JavaScript page cap that stops after 180 extracted result pages; narrow the search URL or raise/lower the cap in the 'Pagination Safety Cap' JavaScript block as needed. AutoScout24 may show cookie consent, CAPTCHA, or anti-bot checks; if a CAPTCHA appears, solve it manually in the browser.",
    "color": "bg-[#4589ff]",
    "template_id": "ai-generated-autoscout24-spain"
  },
  "blocks": [
    {
      "block_id": "navigate-1",
      "block_type": "process",
      "title": "Navigate",
      "description": "Go to a URL",
      "position_x": 120,
      "position_y": 260,
      "config": {
        "url": "https://www.autoscout24.es/lst?atype=C&cy=E&desc=0&sort=standard&source=homepage_search-mask&ustate=N%2CU",
        "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": 260,
      "config": {
        "timeout": 30
      }
    },
    {
      "block_id": "inject-javascript-1",
      "block_type": "process",
      "title": "Inject JavaScript",
      "description": "Execute custom JavaScript",
      "position_x": 840,
      "position_y": 260,
      "config": {
        "jsCode": "(function(){ const btn = Array.from(document.querySelectorAll('button')).find(function(b){ return /(aceptar|accept|agree|permitir)/i.test((b.textContent || '') + ' ' + String(b.className || '')); }); if (btn) { btn.click(); return 'cookie_consent_clicked'; } return 'no_cookie_consent_found'; })();",
        "waitForCompletion": true,
        "timeout": 10
      }
    },
    {
      "block_id": "wait-for-element-1",
      "block_type": "process",
      "title": "Wait for Element",
      "description": "Wait until element appears",
      "position_x": 1200,
      "position_y": 260,
      "config": {
        "selector": "article[data-testid=\"list-item\"]",
        "timeout": 30,
        "visible": true
      }
    },
    {
      "block_id": "structured-export-1",
      "block_type": "process",
      "title": "Structured Export",
      "description": "Export data with custom columns",
      "position_x": 1560,
      "position_y": 260,
      "config": {
        "rowSelector": "article[data-testid=\"list-item\"]",
        "fileName": "autoscout24-spain-scraper.csv",
        "saveLocation": "C:\\Users\\theskd\\Documents\\UScraper\\templates",
        "includeHeaders": true,
        "fileMode": "append",
        "columns": [
          {
            "name": "Marca",
            "selector": "(() => { const text = (ROW.querySelector('h2 span:first-child')?.textContent || ROW.getAttribute('data-make') || '').trim(); return text.replace(/\\s+/g, ' '); })()",
            "attribute": "text",
            "isJs": true
          },
          {
            "name": "Modelo",
            "selector": "(() => { const text = (ROW.querySelector('h2 span:nth-child(2)')?.textContent || ROW.getAttribute('data-model') || '').trim(); return text.replace(/\\s+/g, ' '); })()",
            "attribute": "text",
            "isJs": true
          },
          {
            "name": "Pagina_URL",
            "selector": "(() => { const anchors = Array.from(ROW.querySelectorAll('a[href]')); const ad = anchors.find(a => a.href && a.href.includes('/anuncios/')); if (ad) return ad.href; const id = ROW.getAttribute('data-guid') || ROW.id || ''; return id ? 'https://www.autoscout24.es/anuncios/' + id : ''; })()",
            "attribute": "text",
            "isJs": true
          },
          {
            "name": "Descripcion",
            "selector": "(() => { const candidates = Array.from(ROW.querySelectorAll('p, [class*=Description], [class*=Equipment], [class*=summary], [class*=mia]')).map(e => (e.textContent || '').trim().replace(/\\s+/g, ' ')).filter(Boolean); return candidates.find(t => !/Calcula tu seguro|Vehículos del profesional|Guardar|IVA deducible/i.test(t)) || ''; })()",
            "attribute": "text",
            "isJs": true
          },
          {
            "name": "Precio",
            "selector": "[data-testid=\"regular-price\"]",
            "attribute": "text"
          },
          {
            "name": "Preio_Nivel",
            "selector": "(() => { const el = ROW.querySelector('[class*=PriceLabel] b, [class*=PriceEvaluation] b'); return el ? el.textContent.trim().replace(/\\s+/g, ' ') : ''; })()",
            "attribute": "text",
            "isJs": true
          },
          {
            "name": "Kilometraje",
            "selector": "[data-testid=\"VehicleDetails-mileage_odometer\"] span:last-child",
            "attribute": "text"
          },
          {
            "name": "Tipo_de_cambio",
            "selector": "(() => { const byTestId = Array.from(ROW.querySelectorAll('[data-testid]')).find(e => /transmission|gear|gearbox|shift/i.test(e.getAttribute('data-testid') || '')); if (byTestId) return byTestId.textContent.trim().replace(/\\s+/g, ' '); const full = ((ROW.querySelector('h2')?.textContent || '') + ' ' + (ROW.textContent || '')).replace(/\\s+/g, ' '); if (/\\b(Automático|Automatica|Automatico|Aut\\.?|AUTO|DCT|DSG|CVT|EAT8|S\\s*tronic|Tiptronic|Steptronic|PDK)\\b/i.test(full)) return 'Automático'; if (/\\b(Manual|MT)\\b/i.test(full)) return 'Manual'; return ''; })()",
            "attribute": "text",
            "isJs": true
          },
          {
            "name": "Año",
            "selector": "[data-testid=\"VehicleDetails-calendar\"] span:last-child",
            "attribute": "text"
          },
          {
            "name": "Combustible",
            "selector": "[data-testid=\"VehicleDetails-gas_pump\"] span:last-child",
            "attribute": "text"
          },
          {
            "name": "Potencia",
            "selector": "[data-testid=\"VehicleDetails-speedometer\"] span:last-child",
            "attribute": "text"
          },
          {
            "name": "Distribuidor",
            "selector": "(() => { const seller = ROW.querySelector('[class*=ListItemSeller], [class*=Seller]'); if (!seller) return ''; const lines = (seller.innerText || seller.textContent || '').split(/\\n|\\r/).map(s => s.trim()).filter(Boolean); const line = lines.find(t => !/^ES-/.test(t) && !/Vehículos del profesional|Contact|Contáctanos|Guardar/i.test(t)); return line || ''; })()",
            "attribute": "text",
            "isJs": true
          },
          {
            "name": "Dirección_del_distribuidor",
            "selector": "(() => { const seller = ROW.querySelector('[class*=ListItemSeller], [class*=Seller]'); const text = seller ? (seller.innerText || seller.textContent || '') : (ROW.textContent || ''); const m = text.match(/ES-\\d{4,5}\\s+[^\\n\\r]+/); if (m) return m[0].trim(); const zip = ROW.getAttribute('data-listing-zip-code') || ''; return zip ? 'ES-' + zip : ''; })()",
            "attribute": "text",
            "isJs": true
          },
          {
            "name": "Img_url",
            "selector": "(() => { const source = ROW.querySelector('picture source[srcset*=\"480x360.jpg\"], picture source[srcset*=\"480x360\"]'); if (source) return (source.getAttribute('srcset') || '').split(',')[0].trim().split(' ')[0]; const img = ROW.querySelector('img[data-testid=\"list-item-image\"], img'); return img ? (img.currentSrc || img.src || '') : ''; })()",
            "attribute": "text",
            "isJs": true
          }
        ]
      }
    },
    {
      "block_id": "inject-javascript-2",
      "block_type": "process",
      "title": "Inject JavaScript",
      "description": "Execute custom JavaScript",
      "position_x": 1920,
      "position_y": 260,
      "config": {
        "jsCode": "(function(){ const maxPages = 180; const key = 'uscraper_autoscout24_pages_extracted'; const pageCount = (parseInt(sessionStorage.getItem(key) || '0', 10) || 0) + 1; sessionStorage.setItem(key, String(pageCount)); if (pageCount >= maxPages) { Array.from(document.querySelectorAll('a,button')).filter(function(el){ return /^\\s*Siguiente\\s*$/i.test(el.textContent || ''); }).forEach(function(el){ el.setAttribute('aria-disabled','true'); el.setAttribute('disabled','disabled'); el.classList.add('disabled'); if (el.tagName && el.tagName.toLowerCase() === 'a') el.removeAttribute('href'); }); return 'pagination_cap_reached_' + pageCount; } return 'pagination_page_count_' + pageCount; })();",
        "waitForCompletion": true,
        "timeout": 10
      }
    },
    {
      "block_id": "element-exists-1",
      "block_type": "process",
      "title": "Element Exists",
      "description": "Check if element exists",
      "position_x": 2280,
      "position_y": 260,
      "config": {
        "selector": "(//a[normalize-space()='Siguiente' and @href and not(contains(@class,'disabled')) and not(@aria-disabled='true')] | //button[normalize-space()='Siguiente' and not(@disabled) and not(@aria-disabled='true') and not(contains(@class,'disabled'))])[1]"
      }
    },
    {
      "block_id": "click-1",
      "block_type": "process",
      "title": "Click",
      "description": "Click on element",
      "position_x": 2280,
      "position_y": 620,
      "config": {
        "selector": "(//a[normalize-space()='Siguiente' and @href and not(contains(@class,'disabled')) and not(@aria-disabled='true')] | //button[normalize-space()='Siguiente' and not(@disabled) and not(@aria-disabled='true') and not(contains(@class,'disabled'))])[1]",
        "timeout": 15
      }
    },
    {
      "block_id": "wait-for-page-load-2",
      "block_type": "process",
      "title": "Wait for Page Load",
      "description": "Wait for page to finish loading",
      "position_x": 2640,
      "position_y": 620,
      "config": {
        "timeout": 30
      }
    },
    {
      "block_id": "end-1",
      "block_type": "output",
      "title": "End",
      "description": "Terminate execution flow",
      "position_x": 2280,
      "position_y": 920,
      "config": {}
    }
  ],
  "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": "structured-export-1",
      "to_connector_id": "left"
    },
    {
      "from_block_id": "structured-export-1",
      "from_connector_id": "right",
      "to_block_id": "inject-javascript-2",
      "to_connector_id": "left"
    },
    {
      "from_block_id": "inject-javascript-2",
      "from_connector_id": "right",
      "to_block_id": "element-exists-1",
      "to_connector_id": "left"
    },
    {
      "from_block_id": "element-exists-1",
      "from_connector_id": "true",
      "to_block_id": "click-1",
      "to_connector_id": "left"
    },
    {
      "from_block_id": "element-exists-1",
      "from_connector_id": "false",
      "to_block_id": "end-1",
      "to_connector_id": "left"
    },
    {
      "from_block_id": "click-1",
      "from_connector_id": "right",
      "to_block_id": "wait-for-page-load-2",
      "to_connector_id": "left"
    },
    {
      "from_block_id": "wait-for-page-load-2",
      "from_connector_id": "right",
      "to_block_id": "structured-export-1",
      "to_connector_id": "left"
    }
  ],
  "canvas_elements": [
    {
      "id": "group-load",
      "element_type": "group",
      "title": "Page Load",
      "color": "#08bdba",
      "position_x": 48,
      "position_y": 156,
      "width": 2840,
      "height": 656,
      "z_index": 20,
      "data": {
        "memberBlockIds": [
          "navigate-1",
          "wait-for-page-load-1",
          "wait-for-element-1",
          "wait-for-page-load-2"
        ]
      }
    },
    {
      "id": "group-interaction",
      "element_type": "group",
      "title": "Interaction",
      "color": "#a56eff",
      "position_x": 768,
      "position_y": 156,
      "width": 1400,
      "height": 296,
      "z_index": 20,
      "data": {
        "memberBlockIds": [
          "inject-javascript-1",
          "inject-javascript-2"
        ]
      }
    },
    {
      "id": "group-extract",
      "element_type": "group",
      "title": "Data Extraction",
      "color": "#42be65",
      "position_x": 1488,
      "position_y": 156,
      "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": 156,
      "width": 380,
      "height": 656,
      "z_index": 20,
      "data": {
        "memberBlockIds": [
          "element-exists-1",
          "click-1"
        ]
      }
    },
    {
      "id": "group-control",
      "element_type": "group",
      "title": "Control Flow",
      "color": "#8d8d8d",
      "position_x": 2208,
      "position_y": 816,
      "width": 380,
      "height": 296,
      "z_index": 20,
      "data": {
        "memberBlockIds": [
          "end-1"
        ]
      }
    },
    {
      "id": "note-overview",
      "element_type": "note",
      "title": "Overview",
      "content": "Extracts AutoScout24 Spain car listing data equivalent to the Octoparse template: marca, modelo, listing URL, description/features, price, price level, mileage, transmission/inferred gearbox, year, fuel, power, dealer, dealer address, and image URL. Default start URL is an AutoScout24 Spain search-results page and can be edited to any AutoScout24.es /lst search URL. Pagination uses the Spanish 'Siguiente' next-page control and appends each results page to one CSV. To avoid UScraper's 1000-iteration safety limit on very large AutoScout24 searches, this template includes a JavaScript page cap that stops after 180 extracted result pages; narrow the search URL or raise/lower the cap in the 'Pagination Safety Cap' JavaScript block as needed. AutoScout24 may show cookie consent, CAPTCHA, or anti-bot checks; if a CAPTCHA appears, solve it manually in the browser.",
      "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: `(function(){ const btn = Array.from(document.querySelectorAll('button')).find(function(b){ return /(...` Verify in browser if results are empty.",
      "color": "#ee5396",
      "position_x": 1040,
      "position_y": 240,
      "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 (Marca, Modelo, Pagina_URL, Descripcion, Preio_Nivel). These selectors are fragile — update if the site layout changes.",
      "color": "#ee5396",
      "position_x": 1760,
      "position_y": 240,
      "width": 340,
      "height": 131,
      "z_index": 22,
      "data": {
        "block_id": "structured-export-1"
      }
    },
    {
      "id": "note-block-inject-javascript-2",
      "element_type": "note",
      "title": "Note: Inject JavaScript",
      "content": "Runs custom JavaScript in the page: `(function(){ const maxPages = 180; const key = 'uscraper_autoscout24_pages_extracted'; const pageCou...` Verify in browser if results are empty.",
      "color": "#ee5396",
      "position_x": 2120,
      "position_y": 240,
      "width": 340,
      "height": 140,
      "z_index": 22,
      "data": {
        "block_id": "inject-javascript-2"
      }
    },
    {
      "id": "note-block-element-exists-1",
      "element_type": "note",
      "title": "Note: Element Exists",
      "content": "Condition block: checks `(//a[normalize-space()='Siguiente' and @href and not(contains(@class,'disabled')) and not(@aria-disabled='true')] | //bu`. True / False branches control which path runs next. Keep enough space between branches so both connector lines are visible.",
      "color": "#ee5396",
      "position_x": 2480,
      "position_y": 240,
      "width": 340,
      "height": 170,
      "z_index": 22,
      "data": {
        "block_id": "element-exists-1"
      }
    },
    {
      "id": "note-block-click-1",
      "element_type": "note",
      "title": "Note: Click",
      "content": "Uses XPath `(//a[normalize-space()='Siguiente' and @href and not(contains(@class,'disabled')) and not(@aria-disa`. XPath breaks easily if DOM structure changes.",
      "color": "#ee5396",
      "position_x": 2480,
      "position_y": 600,
      "width": 340,
      "height": 133,
      "z_index": 22,
      "data": {
        "block_id": "click-1"
      }
    }
  ]
}