{
  "version": "1.0.0",
  "exported_at": "2026-05-31T07:55:00.000Z",
  "project": {
    "name": "Amazon Japan Product Scraper",
    "description": "Scrapes Amazon Japan search results for the keyword 'wireless charger' across live-tested pages 1-10 using known search result URLs. Extracts keyword, total result count, rank, ASIN, product name, product URL, price, review/comment count, rating, and page number into amazon-japan-product-scraper.csv. Includes a best-effort anti-bot Continue Shopping handler; Amazon may still show CAPTCHA or block automated access.",
    "color": "bg-[#ff9900]",
    "template_id": "ai-generated"
  },
  "blocks": [
    {
      "block_id": "set-window-size-1",
      "block_type": "process",
      "title": "Set Window Size",
      "description": "Set browser window dimensions",
      "position_x": 120,
      "position_y": 220,
      "config": {
        "width": 1920,
        "height": 1080,
        "color": "bg-[#4589ff]"
      }
    },
    {
      "block_id": "navigate-1",
      "block_type": "process",
      "title": "Navigate",
      "description": "Go to a URL",
      "position_x": 480,
      "position_y": 220,
      "config": {
        "urls": [
          "https://www.amazon.co.jp/s?k=wireless+charger&page=1&language=en_US",
          "https://www.amazon.co.jp/s?k=wireless+charger&page=2&language=en_US",
          "https://www.amazon.co.jp/s?k=wireless+charger&page=3&language=en_US",
          "https://www.amazon.co.jp/s?k=wireless+charger&page=4&language=en_US",
          "https://www.amazon.co.jp/s?k=wireless+charger&page=5&language=en_US",
          "https://www.amazon.co.jp/s?k=wireless+charger&page=6&language=en_US",
          "https://www.amazon.co.jp/s?k=wireless+charger&page=7&language=en_US",
          "https://www.amazon.co.jp/s?k=wireless+charger&page=8&language=en_US",
          "https://www.amazon.co.jp/s?k=wireless+charger&page=9&language=en_US",
          "https://www.amazon.co.jp/s?k=wireless+charger&page=10&language=en_US"
        ],
        "color": "bg-[#4589ff]",
        "tags": [
          "amazon",
          "search",
          "pagination"
        ]
      }
    },
    {
      "block_id": "wait-for-page-load-1",
      "block_type": "process",
      "title": "Wait for Page Load",
      "description": "Wait for page to finish loading",
      "position_x": 840,
      "position_y": 220,
      "config": {
        "timeout": 45,
        "color": "bg-[#08bdba]"
      }
    },
    {
      "block_id": "element-exists-1",
      "block_type": "process",
      "title": "Element Exists",
      "description": "Check if element exists",
      "position_x": 1200,
      "position_y": 220,
      "config": {
        "selector": "form[action*='/errors/validateCaptcha'] button[type='submit'], form[action*='/errors/validateCaptcha'] .a-button-text",
        "color": "bg-[#ff832b]"
      }
    },
    {
      "block_id": "click-1",
      "block_type": "process",
      "title": "Click",
      "description": "Click on element",
      "position_x": 1560,
      "position_y": 120,
      "config": {
        "selector": "form[action*='/errors/validateCaptcha'] button[type='submit'], form[action*='/errors/validateCaptcha'] .a-button-text",
        "timeout": 10,
        "color": "bg-[#a56eff]"
      }
    },
    {
      "block_id": "sleep-1",
      "block_type": "process",
      "title": "Sleep",
      "description": "Wait for specified time",
      "position_x": 1920,
      "position_y": 120,
      "config": {
        "duration": 3,
        "color": "bg-[#08bdba]"
      }
    },
    {
      "block_id": "wait-for-element-1",
      "block_type": "process",
      "title": "Wait for Element",
      "description": "Wait until element appears",
      "position_x": 2280,
      "position_y": 120,
      "config": {
        "selector": "div.s-main-slot div[data-component-type='s-search-result'][data-asin]:not([data-asin=''])",
        "timeout": 45,
        "visible": true,
        "color": "bg-[#08bdba]"
      }
    },
    {
      "block_id": "wait-for-element-2",
      "block_type": "process",
      "title": "Wait for Element",
      "description": "Wait until element appears",
      "position_x": 1560,
      "position_y": 540,
      "config": {
        "selector": "div.s-main-slot 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": 2640,
      "position_y": 320,
      "config": {
        "rowSelector": "div.s-main-slot div[data-component-type='s-search-result'][data-asin]:not([data-asin=''])",
        "fileName": "amazon-japan-product-scraper.csv",
        "saveLocation": "C:\\Users\\theskd\\Documents\\UScraper\\templates",
        "includeHeaders": true,
        "fileMode": "append",
        "color": "bg-[#42be65]",
        "tags": [
          "products",
          "csv",
          "structured-export"
        ],
        "columns": [
          {
            "name": "keyword",
            "selector": "new URL(location.href).searchParams.get('k') || new URL(location.href).searchParams.get('keywords') || 'wireless charger'",
            "attribute": "text",
            "isJs": true
          },
          {
            "name": "search_results",
            "selector": "((document.body.innerText.match(/of\\s+([0-9,]+)\\s+results/i) || document.body.innerText.match(/([0-9,]+)\\s+results/i) || document.body.innerText.match(/検索結果\\s*([0-9,]+)/)) || [])[1] || ''",
            "attribute": "text",
            "isJs": true
          },
          {
            "name": "rank",
            "selector": "(() => { const a = ROW.querySelector('h2 a[href*=\"/dp/\"], a.a-link-normal[href*=\"/dp/\"]'); const href = a ? a.href : ''; const m = href.match(/[?&]sr=8-(\\d+)/); if (m) return m[1]; const idx = ROW.getAttribute('data-index') || ''; const page = parseInt(new URL(location.href).searchParams.get('page') || '1', 10); const n = parseInt(idx, 10); return Number.isFinite(n) ? String((page - 1) * 48 + n) : idx; })()",
            "attribute": "text",
            "isJs": true
          },
          {
            "name": "asin",
            "selector": "ROW.getAttribute('data-asin') || ''",
            "attribute": "text",
            "isJs": true
          },
          {
            "name": "product_name",
            "selector": "((ROW.querySelector('h2 span') || ROW.querySelector('[data-cy=\"title-recipe\"] span') || ROW.querySelector('.a-text-normal'))?.textContent || '').trim()",
            "attribute": "text",
            "isJs": true
          },
          {
            "name": "product_url",
            "selector": "(() => { const a = ROW.querySelector('h2 a[href*=\"/dp/\"], a.a-link-normal[href*=\"/dp/\"]'); return a ? new URL(a.getAttribute('href'), location.origin).href : ''; })()",
            "attribute": "text",
            "isJs": true
          },
          {
            "name": "price",
            "selector": "((ROW.querySelector('.a-price .a-offscreen')?.textContent || '').replace(/[¥￥]/g, '').trim())",
            "attribute": "text",
            "isJs": true
          },
          {
            "name": "comment_count",
            "selector": "((ROW.querySelector('a[href*=\"customerReviews\"] .s-underline-text') || ROW.querySelector('.s-underline-text'))?.textContent || '').replace(/[()]/g, '').trim()",
            "attribute": "text",
            "isJs": true
          },
          {
            "name": "rating",
            "selector": "((ROW.querySelector('i.a-icon-star-small span.a-icon-alt') || ROW.querySelector('span.a-icon-alt'))?.textContent || '').trim()",
            "attribute": "text",
            "isJs": true
          },
          {
            "name": "page_number",
            "selector": "new URL(location.href).searchParams.get('page') || '1'",
            "attribute": "text",
            "isJs": true
          }
        ]
      }
    },
    {
      "block_id": "sleep-2",
      "block_type": "process",
      "title": "Sleep",
      "description": "Wait for specified time",
      "position_x": 3000,
      "position_y": 320,
      "config": {
        "duration": 2,
        "color": "bg-[#ff832b]"
      }
    },
    {
      "block_id": "loop-continue-1",
      "block_type": "process",
      "title": "Loop Continue",
      "description": "Continue multi-input loop",
      "position_x": 3360,
      "position_y": 320,
      "config": {
        "color": "bg-[#8d8d8d]"
      }
    }
  ],
  "connections": [
    {
      "from_block_id": "set-window-size-1",
      "from_connector_id": "right",
      "to_block_id": "navigate-1",
      "to_connector_id": "left"
    },
    {
      "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": "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-2",
      "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": "wait-for-element-2",
      "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": "sleep-2",
      "to_connector_id": "left"
    },
    {
      "from_block_id": "sleep-2",
      "from_connector_id": "right",
      "to_block_id": "loop-continue-1",
      "to_connector_id": "left"
    }
  ],
  "canvas_elements": [
    {
      "id": "group-entry",
      "element_type": "group",
      "title": "Entry & Setup",
      "color": "#4589ff",
      "position_x": 48,
      "position_y": 116,
      "width": 380,
      "height": 296,
      "z_index": 20,
      "data": {
        "memberBlockIds": [
          "set-window-size-1"
        ]
      }
    },
    {
      "id": "group-load",
      "element_type": "group",
      "title": "Page Load",
      "color": "#08bdba",
      "position_x": 408,
      "position_y": 16,
      "width": 2840,
      "height": 716,
      "z_index": 20,
      "data": {
        "memberBlockIds": [
          "navigate-1",
          "wait-for-page-load-1",
          "sleep-1",
          "wait-for-element-1",
          "wait-for-element-2",
          "sleep-2"
        ]
      }
    },
    {
      "id": "group-pagination",
      "element_type": "group",
      "title": "Pagination Loop",
      "color": "#ff832b",
      "position_x": 1128,
      "position_y": 16,
      "width": 2480,
      "height": 496,
      "z_index": 20,
      "data": {
        "memberBlockIds": [
          "element-exists-1",
          "click-1",
          "loop-continue-1"
        ]
      }
    },
    {
      "id": "group-extract",
      "element_type": "group",
      "title": "Data Extraction",
      "color": "#42be65",
      "position_x": 2568,
      "position_y": 216,
      "width": 380,
      "height": 296,
      "z_index": 20,
      "data": {
        "memberBlockIds": [
          "structured-export-1"
        ]
      }
    },
    {
      "id": "note-overview",
      "element_type": "note",
      "title": "Overview",
      "content": "Scrapes Amazon Japan search results for the keyword 'wireless charger' across live-tested pages 1-10 using known search result URLs. Extracts keyword, total result count, rank, ASIN, product name, product URL, price, review/comment count, rating, and page number into amazon-japan-product-scraper.csv. Includes a best-effort anti-bot Continue Shopping handler; Amazon may still show CAPTCHA or block automated access.",
      "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'] .a-button-text`. True / False branches control which path runs next. Keep enough space between branches so both connector lines are visible.",
      "color": "#ee5396",
      "position_x": 1400,
      "position_y": 200,
      "width": 340,
      "height": 169,
      "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, search_results, rank, asin, product_name). These selectors are fragile — update if the site layout changes.",
      "color": "#ee5396",
      "position_x": 2840,
      "position_y": 300,
      "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": 3560,
      "position_y": 300,
      "width": 340,
      "height": 123,
      "z_index": 22,
      "data": {
        "block_id": "loop-continue-1"
      }
    }
  ]
}