{
  "version": "1.0.0",
  "exported_at": "2026-05-31T20:15:00.000Z",
  "project": {
    "name": "Amazon Prime Scraper",
    "description": "Scrapes Amazon US Prime-filtered search listing data equivalent to the Octoparse Amazon Prime Scraper: listing URL, detected ZIP code, title, price, ASIN, product URL, keyword, stars, rating count, and current time. Pagination is handled by clicking Amazon's enabled Next button until no further result page is available. Amazon may show CAPTCHA or vary results by session/location; set the desired delivery ZIP in the browser profile before running.",
    "color": "bg-[#ff9900]",
    "template_id": "ai-generated-amazon-prime-scraper"
  },
  "blocks": [
    {
      "block_id": "navigate-1",
      "block_type": "process",
      "title": "Navigate",
      "description": "Go to a URL",
      "position_x": 120,
      "position_y": 240,
      "config": {
        "url": "https://www.amazon.com/s?k=hair%2Bcare%2B&rh=p_85%3A2470955011&page=1&language=en_US&qid=1654754738",
        "color": "bg-[#4589ff]",
        "tags": [
          "amazon",
          "prime",
          "search-results"
        ]
      }
    },
    {
      "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": 45,
        "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": "div[data-component-type=\"s-search-result\"][data-asin]:not([data-asin=\"\"])",
        "timeout": 45,
        "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": "div[data-component-type=\"s-search-result\"][data-asin]:not([data-asin=\"\"])",
        "fileName": "amazon-prime-scraper.csv",
        "saveLocation": "C:\\Users\\theskd\\Documents\\UScraper\\templates",
        "includeHeaders": true,
        "fileMode": "append",
        "color": "bg-[#42be65]",
        "columns": [
          {
            "name": "listing_url",
            "selector": "window.location.href",
            "attribute": "text",
            "isJs": true
          },
          {
            "name": "zip_code",
            "selector": "(() => { const txt = (document.querySelector('#glow-ingress-line1')?.textContent || document.querySelector('#nav-global-location-popover-link')?.textContent || '').trim(); const m = txt.match(/\\b\\d{5}(?:-\\d{4})?\\b/); return m ? m[0] : ''; })()",
            "attribute": "text",
            "isJs": true
          },
          {
            "name": "title",
            "selector": "(() => { const el = ROW.querySelector('h2 span'); return el ? el.textContent.trim().replace(/\\s+/g, ' ') : ''; })()",
            "attribute": "text",
            "isJs": true
          },
          {
            "name": "price",
            "selector": "(() => { const el = ROW.querySelector('.a-price .a-offscreen'); return el ? el.textContent.trim() : ''; })()",
            "attribute": "text",
            "isJs": true
          },
          {
            "name": "asin",
            "selector": "(() => { const asin = ROW.getAttribute('data-asin'); if (asin) return asin; const href = ROW.querySelector('a[href*=\"/dp/\"], a[href*=\"/gp/product/\"]')?.href || ''; const m = href.match(/\\/(?:dp|gp\\/product)\\/([A-Z0-9]{10})/); return m ? m[1] : ''; })()",
            "attribute": "text",
            "isJs": true
          },
          {
            "name": "product_url",
            "selector": "(() => { const a = ROW.querySelector('a[href*=\"/dp/\"], a[href*=\"/gp/product/\"]'); return a ? new URL(a.getAttribute('href'), location.origin).href : ''; })()",
            "attribute": "text",
            "isJs": true
          },
          {
            "name": "keyword",
            "selector": "(() => { const raw = new URLSearchParams(location.search).get('k') || ''; return decodeURIComponent(raw).replace(/\\+/g, ' ').trim(); })()",
            "attribute": "text",
            "isJs": true
          },
          {
            "name": "stars",
            "selector": "(() => { const nodes = Array.from(ROW.querySelectorAll('[aria-label], .a-icon-alt, i[class*=\"a-icon-star\"] span, span.a-size-small.a-color-base')); for (const el of nodes) { const raw = ((el.getAttribute('aria-label') || '') + ' ' + (el.textContent || '')).trim().replace(/\\s+/g, ' '); const full = raw.match(/\\d+(?:\\.\\d+)?\\s*out of\\s*5 stars/i); if (full) return full[0].replace(/\\s+/g, ' '); } const numeric = Array.from(ROW.querySelectorAll('span.a-size-small.a-color-base, .a-icon-alt')).map(el => (el.textContent || '').trim()).find(v => /^\\d+(?:\\.\\d+)?$/.test(v)); return numeric ? `${numeric} out of 5 stars` : ''; })()",
            "attribute": "text",
            "isJs": true
          },
          {
            "name": "rating_count",
            "selector": "(() => { const links = Array.from(ROW.querySelectorAll('a[href*=\"customerReviews\"], a[href*=\"#customerReviews\"]')); const link = links.find(a => /[\\d,.]+\\s*[Kk]?/.test((a.textContent || '').trim())); return link ? link.textContent.trim().replace(/[()]/g, '') : ''; })()",
            "attribute": "text",
            "isJs": true
          },
          {
            "name": "current_time",
            "selector": "new Date().toLocaleString()",
            "attribute": "text",
            "isJs": true
          }
        ]
      }
    },
    {
      "block_id": "element-exists-1",
      "block_type": "process",
      "title": "Element Exists",
      "description": "Check if element exists",
      "position_x": 1560,
      "position_y": 240,
      "config": {
        "selector": "a.s-pagination-next:not(.s-pagination-disabled)",
        "color": "bg-[#ff832b]"
      }
    },
    {
      "block_id": "click-1",
      "block_type": "process",
      "title": "Click",
      "description": "Click on element",
      "position_x": 1920,
      "position_y": 240,
      "config": {
        "selector": "a.s-pagination-next:not(.s-pagination-disabled)",
        "timeout": 20,
        "color": "bg-[#ff832b]"
      }
    },
    {
      "block_id": "wait-for-page-load-2",
      "block_type": "process",
      "title": "Wait for Page Load",
      "description": "Wait for page to finish loading",
      "position_x": 2280,
      "position_y": 240,
      "config": {
        "timeout": 45,
        "color": "bg-[#08bdba]"
      }
    },
    {
      "block_id": "wait-for-element-2",
      "block_type": "process",
      "title": "Wait for Element",
      "description": "Wait until element appears",
      "position_x": 2640,
      "position_y": 240,
      "config": {
        "selector": "div[data-component-type=\"s-search-result\"][data-asin]:not([data-asin=\"\"])",
        "timeout": 45,
        "visible": true,
        "color": "bg-[#08bdba]"
      }
    },
    {
      "block_id": "sleep-1",
      "block_type": "process",
      "title": "Sleep",
      "description": "Wait for specified time",
      "position_x": 3000,
      "position_y": 560,
      "config": {
        "duration": 2,
        "color": "bg-[#8d8d8d]"
      }
    },
    {
      "block_id": "end-1",
      "block_type": "output",
      "title": "End",
      "description": "Terminate execution flow",
      "position_x": 1560,
      "position_y": 600,
      "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": "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": "wait-for-element-2",
      "to_connector_id": "left"
    },
    {
      "from_block_id": "wait-for-element-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": "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": 136,
      "width": 3200,
      "height": 616,
      "z_index": 20,
      "data": {
        "memberBlockIds": [
          "navigate-1",
          "wait-for-page-load-1",
          "wait-for-element-1",
          "wait-for-page-load-2",
          "wait-for-element-2",
          "sleep-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": 680,
      "height": 296,
      "z_index": 20,
      "data": {
        "memberBlockIds": [
          "element-exists-1",
          "click-1"
        ]
      }
    },
    {
      "id": "group-control",
      "element_type": "group",
      "title": "Control Flow",
      "color": "#8d8d8d",
      "position_x": 1488,
      "position_y": 496,
      "width": 380,
      "height": 296,
      "z_index": 20,
      "data": {
        "memberBlockIds": [
          "end-1"
        ]
      }
    },
    {
      "id": "note-overview",
      "element_type": "note",
      "title": "Overview",
      "content": "Scrapes Amazon US Prime-filtered search listing data equivalent to the Octoparse Amazon Prime Scraper: listing URL, detected ZIP code, title, price, ASIN, product URL, keyword, stars, rating count, and current time. Pagination is handled by clicking Amazon's enabled Next button until no further result page is available. Amazon may show CAPTCHA or vary results by session/location; set the desired delivery ZIP in the browser profile before running.",
      "color": "#f1c21b",
      "position_x": 80,
      "position_y": 20,
      "width": 480,
      "height": 160,
      "z_index": 22,
      "data": {}
    },
    {
      "id": "note-block-structured-export-1",
      "element_type": "note",
      "title": "Note: Structured Export",
      "content": "Structured export with JS columns (listing_url, zip_code, title, price, asin). These selectors are fragile — update if the site layout changes.",
      "color": "#ee5396",
      "position_x": 1400,
      "position_y": 220,
      "width": 340,
      "height": 127,
      "z_index": 22,
      "data": {
        "block_id": "structured-export-1"
      }
    },
    {
      "id": "note-block-element-exists-1",
      "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": 1760,
      "position_y": 220,
      "width": 340,
      "height": 146,
      "z_index": 22,
      "data": {
        "block_id": "element-exists-1"
      }
    },
    {
      "id": "note-block-click-1",
      "element_type": "note",
      "title": "Note: Click",
      "content": "Pagination click — add waits after this block; the page reloads asynchronously.",
      "color": "#ee5396",
      "position_x": 2120,
      "position_y": 220,
      "width": 316,
      "height": 106,
      "z_index": 22,
      "data": {
        "block_id": "click-1"
      }
    }
  ]
}