{
  "version": "1.0.0",
  "exported_at": "2026-06-01T04:00:00.000Z",
  "project": {
    "name": "Amazon Product Listing Scraperfor Spain",
    "description": "Best-effort Amazon.es product listing scraper for keyword search results. Starts with keyword 'cable', extracts Keyword, ASIN, Title, Detail_Page_URL, Star_Rating, Number_of_Reviews, Price, and Current_Time from Amazon search result cards. Uses click-next pagination and appends all result pages until the Amazon next button is disabled or missing. Amazon may show anti-bot/CAPTCHA pages; if that occurs, manually solve/continue in the browser and rerun or resume. Detail URLs use a robust JS extractor with canonical /dp/{ASIN} fallback.",
    "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": {
        "url": "https://www.amazon.es/s?k=cable&page=1&language=es_ES",
        "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": 456,
      "position_y": 220,
      "config": {
        "timeout": 30
      }
    },
    {
      "block_id": "element-exists-1",
      "block_type": "process",
      "title": "Element Exists",
      "description": "Check if element exists",
      "position_x": 792,
      "position_y": 220,
      "config": {
        "selector": "form[action*='/errors/validateCaptcha'] button[type='submit'], form[action*='/errors/validateCaptcha'] button.a-button-text"
      }
    },
    {
      "block_id": "click-1",
      "block_type": "process",
      "title": "Click",
      "description": "Click on element",
      "position_x": 1128,
      "position_y": 520,
      "config": {
        "selector": "form[action*='/errors/validateCaptcha'] button[type='submit'], form[action*='/errors/validateCaptcha'] button.a-button-text",
        "timeout": 10
      }
    },
    {
      "block_id": "wait-for-page-load-2",
      "block_type": "process",
      "title": "Wait for Page Load",
      "description": "Wait for page to finish loading",
      "position_x": 1464,
      "position_y": 520,
      "config": {
        "timeout": 30
      }
    },
    {
      "block_id": "sleep-1",
      "block_type": "process",
      "title": "Sleep",
      "description": "Wait for specified time",
      "position_x": 1800,
      "position_y": 520,
      "config": {
        "duration": 2
      }
    },
    {
      "block_id": "wait-for-element-1",
      "block_type": "process",
      "title": "Wait for Element",
      "description": "Wait until element appears",
      "position_x": 2136,
      "position_y": 520,
      "config": {
        "selector": "div.s-main-slot div[data-component-type='s-search-result'][data-asin]",
        "timeout": 45,
        "visible": true
      }
    },
    {
      "block_id": "structured-export-1",
      "block_type": "process",
      "title": "Structured Export",
      "description": "Export data with custom columns",
      "position_x": 2472,
      "position_y": 520,
      "config": {
        "rowSelector": "div.s-main-slot div[data-component-type='s-search-result'][data-asin]",
        "fileName": "amazon-espana-listados-scraper.csv",
        "saveLocation": "C:\\Users\\theskd\\Documents\\UScraper\\templates",
        "includeHeaders": true,
        "fileMode": "append",
        "columns": [
          {
            "name": "keyword",
            "selector": "(() => { try { return new URL(window.location.href).searchParams.get('k') || 'cable'; } catch (e) { return 'cable'; } })()",
            "attribute": "text",
            "isJs": true
          },
          {
            "name": "asin",
            "selector": "",
            "attribute": "data-asin"
          },
          {
            "name": "title",
            "selector": "h2 span",
            "attribute": "text"
          },
          {
            "name": "detail_page_url",
            "selector": "(() => { const asin = ROW.getAttribute('data-asin') || ''; const links = Array.from(ROW.querySelectorAll('a[href]')); const direct = links.map(a => a.getAttribute('href') || '').find(h => /\\/dp\\/[A-Z0-9]{10}/.test(h)); if (direct) { try { return new URL(direct, window.location.origin).href; } catch (e) { return direct; } } const encoded = links.map(a => a.getAttribute('href') || '').find(h => /%2Fdp%2F[A-Z0-9]{10}/i.test(h)); if (encoded) { try { const decoded = decodeURIComponent(encoded); const m = decoded.match(/\\/[^?\\s]*\\/dp\\/[A-Z0-9]{10}[^?\\s]*/); if (m) return new URL(m[0], window.location.origin).href; } catch (e) {} } return asin ? ('https://www.amazon.es/dp/' + asin) : ''; })()",
            "attribute": "text",
            "isJs": true
          },
          {
            "name": "star_rating",
            "selector": "(() => { const candidates = Array.from(ROW.querySelectorAll('[aria-label], [title], .a-icon-alt, i, span')).map(el => (el.getAttribute('aria-label') || el.getAttribute('title') || el.textContent || '').trim()).filter(Boolean); const hit = candidates.find(t => /\\d+(?:[,.]\\d+)?\\s*(?:de|sobre|out of)\\s*5/i.test(t) || /\\d+(?:[,.]\\d+)?\\s*estrellas/i.test(t)); if (hit) return hit; const txt = ROW.textContent || ''; const m = txt.match(/\\d+(?:[,.]\\d+)?\\s*(?:de|sobre|out of)\\s*5(?:\\s*estrellas)?/i); return m ? m[0] : ''; })()",
            "attribute": "text",
            "isJs": true
          },
          {
            "name": "number_of_reviews",
            "selector": "(() => { const links = Array.from(ROW.querySelectorAll('a[href*=customerReviews], a[href*=\"#customerReviews\"], a[aria-label]')); const hit = links.find(a => /\\d/.test((a.textContent || '') + (a.getAttribute('aria-label') || ''))); if (hit) return (hit.textContent || hit.getAttribute('aria-label') || '').replace(/[()]/g, '').trim(); const txt = ROW.textContent || ''; const m = txt.match(/\\(?\\d+[\\d.,\\s\\u00a0]*(?:mil)?\\)?(?=\\s*(?:valoraciones|opiniones|reseñas)?)/i); return m ? m[0].replace(/[()]/g, '').trim() : ''; })()",
            "attribute": "text",
            "isJs": true
          },
          {
            "name": "price",
            "selector": ".a-price .a-offscreen",
            "attribute": "text"
          },
          {
            "name": "current_time",
            "selector": "new Date().toLocaleString('es-ES')",
            "attribute": "text",
            "isJs": true
          }
        ]
      }
    },
    {
      "block_id": "element-exists-2",
      "block_type": "process",
      "title": "Element Exists",
      "description": "Check if element exists",
      "position_x": 2808,
      "position_y": 520,
      "config": {
        "selector": "a.s-pagination-next:not(.s-pagination-disabled)"
      }
    },
    {
      "block_id": "click-2",
      "block_type": "process",
      "title": "Click",
      "description": "Click on element",
      "position_x": 3144,
      "position_y": 520,
      "config": {
        "selector": "a.s-pagination-next:not(.s-pagination-disabled)",
        "timeout": 15
      }
    },
    {
      "block_id": "wait-for-page-load-3",
      "block_type": "process",
      "title": "Wait for Page Load",
      "description": "Wait for page to finish loading",
      "position_x": 3480,
      "position_y": 520,
      "config": {
        "timeout": 30
      }
    },
    {
      "block_id": "sleep-2",
      "block_type": "process",
      "title": "Sleep",
      "description": "Wait for specified time",
      "position_x": 3816,
      "position_y": 758,
      "config": {
        "duration": 2
      }
    },
    {
      "block_id": "end-1",
      "block_type": "output",
      "title": "End",
      "description": "Terminate execution flow",
      "position_x": 2808,
      "position_y": 520,
      "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": "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": "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": "sleep-1",
      "to_connector_id": "left"
    },
    {
      "from_block_id": "sleep-1",
      "from_connector_id": "right",
      "to_block_id": "wait-for-element-1",
      "to_connector_id": "left"
    },
    {
      "from_block_id": "element-exists-1",
      "from_connector_id": "false",
      "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": "element-exists-2",
      "to_connector_id": "left"
    },
    {
      "from_block_id": "element-exists-2",
      "from_connector_id": "true",
      "to_block_id": "click-2",
      "to_connector_id": "left"
    },
    {
      "from_block_id": "click-2",
      "from_connector_id": "right",
      "to_block_id": "wait-for-page-load-3",
      "to_connector_id": "left"
    },
    {
      "from_block_id": "wait-for-page-load-3",
      "from_connector_id": "right",
      "to_block_id": "sleep-2",
      "to_connector_id": "left"
    },
    {
      "from_block_id": "sleep-2",
      "from_connector_id": "right",
      "to_block_id": "wait-for-element-1",
      "to_connector_id": "left"
    },
    {
      "from_block_id": "element-exists-2",
      "from_connector_id": "false",
      "to_block_id": "end-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": 4016,
      "height": 834,
      "z_index": 20,
      "data": {
        "memberBlockIds": [
          "navigate-1",
          "wait-for-page-load-1",
          "wait-for-page-load-2",
          "sleep-1",
          "wait-for-element-1",
          "wait-for-page-load-3",
          "sleep-2"
        ]
      }
    },
    {
      "id": "group-pagination",
      "element_type": "group",
      "title": "Pagination Loop",
      "color": "#ff832b",
      "position_x": 720,
      "position_y": 116,
      "width": 2672,
      "height": 596,
      "z_index": 20,
      "data": {
        "memberBlockIds": [
          "element-exists-1",
          "click-1",
          "element-exists-2",
          "click-2"
        ]
      }
    },
    {
      "id": "group-extract",
      "element_type": "group",
      "title": "Data Extraction",
      "color": "#42be65",
      "position_x": 2400,
      "position_y": 416,
      "width": 380,
      "height": 296,
      "z_index": 20,
      "data": {
        "memberBlockIds": [
          "structured-export-1"
        ]
      }
    },
    {
      "id": "group-control",
      "element_type": "group",
      "title": "Control Flow",
      "color": "#8d8d8d",
      "position_x": 2736,
      "position_y": 416,
      "width": 380,
      "height": 296,
      "z_index": 20,
      "data": {
        "memberBlockIds": [
          "end-1"
        ]
      }
    },
    {
      "id": "note-overview",
      "element_type": "note",
      "title": "Overview",
      "content": "Best-effort Amazon.es product listing scraper for keyword search results. Starts with keyword 'cable', extracts Keyword, ASIN, Title, Detail_Page_URL, Star_Rating, Number_of_Reviews, Price, and Current_Time from Amazon search result cards. Uses click-next pagination and appends all result pages until the Amazon next button is disabled or missing. Amazon may show anti-bot/CAPTCHA pages; if that occurs, manually solve/continue in the browser and rerun or resume. Detail URLs use a robust JS extractor with canonical /dp/{ASIN} fallback.",
      "color": "#f1c21b",
      "position_x": 80,
      "position_y": 20,
      "width": 480,
      "height": 160,
      "z_index": 22,
      "data": {}
    },
    {
      "id": "note-block-element-exists-1",
      "element_type": "note",
      "title": "Note: Element Exists",
      "content": "Condition block: checks `form[action*='/errors/validateCaptcha'] button[type='submit'], form[action*='/errors/validateCaptcha'] button.a-button-t`. True / False branches control which path runs next. Keep enough space between branches so both connector lines are visible.",
      "color": "#ee5396",
      "position_x": 992,
      "position_y": 200,
      "width": 340,
      "height": 170,
      "z_index": 22,
      "data": {
        "block_id": "element-exists-1"
      }
    },
    {
      "id": "note-block-structured-export-1",
      "element_type": "note",
      "title": "Note: Structured Export",
      "content": "Structured export with JS columns (keyword, detail_page_url, star_rating, number_of_reviews, current_time). These selectors are fragile — update if the site layout changes.",
      "color": "#ee5396",
      "position_x": 2672,
      "position_y": 500,
      "width": 340,
      "height": 137,
      "z_index": 22,
      "data": {
        "block_id": "structured-export-1"
      }
    },
    {
      "id": "note-block-element-exists-2",
      "element_type": "note",
      "title": "Note: Element Exists",
      "content": "Condition block: checks `a.s-pagination-next:not(.s-pagination-disabled)`. True / False branches control which path runs next. Keep enough space between branches so both connector lines are visible.",
      "color": "#ee5396",
      "position_x": 3008,
      "position_y": 500,
      "width": 340,
      "height": 146,
      "z_index": 22,
      "data": {
        "block_id": "element-exists-2"
      }
    },
    {
      "id": "note-block-click-2",
      "element_type": "note",
      "title": "Note: Click",
      "content": "Pagination click — add waits after this block; the page reloads asynchronously.",
      "color": "#ee5396",
      "position_x": 3344,
      "position_y": 500,
      "width": 316,
      "height": 106,
      "z_index": 22,
      "data": {
        "block_id": "click-2"
      }
    }
  ]
}