{
  "version": "1.0.0",
  "exported_at": "2026-06-02T16:15:00.000Z",
  "project": {
    "name": "HKTVmall Scraper",
    "description": "Best-effort HKTVmall product scraper equivalent to the Octoparse HKTVmall template. The original keyword search-results selector was not available during autonomous execution, so this version scrapes the provided HKTVmall Dettol product detail URLs directly and extracts the same kind of fields: input keyword, title, URL, price, RSP/original price, image URL, promotion label, merchant, packing, sold count, review count, delivery label, and Macau shipping flag. Navigation uses a predefined URL list with loop-continue and appends all product rows to hktvmall-scraper.csv. Add more HKTVmall product URLs to navigate.urls to expand coverage.",
    "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://www.hktvmall.com/hktv/en/main/GC-Mart/s/H9527001/Personal-Care-%26-Health/Personal-Care-%26-Health/Personal-Care/Hand-Care/Hand-Wash/Antibacterial-Hand-Wash-Refill-Original-900ml-parallel-import/p/H9527001_S_DETTOL-HANDWASH-04",
          "https://www.hktvmall.com/hktv/en/main/Dettol/s/H1010002/Supermarket/Supermarket/Household-Cleaners/Bleach-%26-Antiseptics/Dettol-Antiseptic-Liquid-12L-Twin-Pack-Dettol-Laundry-Sanitiser-Random-Variant-750ml/p/H0888001_S_10131182"
        ],
        "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
      }
    },
    {
      "block_id": "wait-for-element-1",
      "block_type": "process",
      "title": "Wait for Element",
      "description": "Wait until element appears",
      "position_x": 840,
      "position_y": 220,
      "config": {
        "selector": "h1",
        "timeout": 30,
        "visible": true
      }
    },
    {
      "block_id": "sleep-1",
      "block_type": "process",
      "title": "Sleep",
      "description": "Wait for specified time",
      "position_x": 1200,
      "position_y": 220,
      "config": {
        "duration": 1
      }
    },
    {
      "block_id": "structured-export-1",
      "block_type": "process",
      "title": "Structured Export",
      "description": "Export data with custom columns",
      "position_x": 1560,
      "position_y": 220,
      "config": {
        "rowSelector": "body",
        "fileName": "hktvmall-scraper.csv",
        "saveLocation": "C:\\Users\\theskd\\Documents\\UScraper\\templates",
        "includeHeaders": true,
        "fileMode": "append",
        "columns": [
          {
            "name": "input_keyword",
            "selector": "'dettol'",
            "attribute": "text",
            "isJs": true
          },
          {
            "name": "title",
            "selector": "(() => { const h = ROW.querySelector('h1'); return h ? h.textContent.replace(/\\s+/g, ' ').trim() : (document.querySelector('meta[property=\"og:title\"]')?.content || document.title || '').replace(/\\s+/g, ' ').trim(); })()",
            "attribute": "text",
            "isJs": true
          },
          {
            "name": "title_url",
            "selector": "window.location.href",
            "attribute": "text",
            "isJs": true
          },
          {
            "name": "price",
            "selector": "(() => { const text = ROW.innerText.replace(/\\s+/g, ' ').trim(); let m = text.match(/Special Price\\s*\\$\\s*([\\d,.]+)\\s*\\$\\s*([\\d,.]+)/i); if (m) return '$ ' + m[2]; m = text.match(/(?:Special Price|Price)\\s*\\$\\s*([\\d,.]+)/i); if (m) return '$ ' + m[1]; const prices = Array.from(ROW.querySelectorAll('.price')).map(e => e.textContent.replace(/\\s+/g, ' ').trim()).filter(t => /\\$/.test(t)); return prices[0] || ''; })()",
            "attribute": "text",
            "isJs": true
          },
          {
            "name": "RSP",
            "selector": "(() => { const text = ROW.innerText.replace(/\\s+/g, ' ').trim(); const m = text.match(/Special Price\\s*\\$\\s*([\\d,.]+)\\s*\\$\\s*([\\d,.]+)/i); if (m) return '$ ' + m[1]; const prices = Array.from(ROW.querySelectorAll('.price')).map(e => e.textContent.replace(/\\s+/g, ' ').trim()).filter(t => /\\$/.test(t)); return prices.length > 1 ? prices[1] : ''; })()",
            "attribute": "text",
            "isJs": true
          },
          {
            "name": "img_link",
            "selector": "(() => { const og = document.querySelector('meta[property=\"og:image:secure_url\"]')?.content || document.querySelector('meta[property=\"og:image\"]')?.content; if (og) return og; const img = ROW.querySelector('.productImage img, .product-image img, img[src*=\"uploadProductImage\"], img'); return img ? (img.getAttribute('data-src') || img.getAttribute('data-original') || img.src || '') : ''; })()",
            "attribute": "text",
            "isJs": true
          },
          {
            "name": "promotion_label",
            "selector": "(() => { const full = ROW.innerText.replace(/\\s+/g, ' ').trim(); const h = ROW.querySelector('h1'); const title = h ? h.textContent.replace(/\\s+/g, ' ').trim() : ''; const start = title ? full.indexOf(title) : -1; let top = start >= 0 ? full.slice(start, start + 1200) : full.slice(0, 1200); const stopWords = ['Delivery / Return', 'Sold by', 'Qty Add to Cart', 'Add to Cart', 'Description Customer Review']; for (const w of stopWords) { const i = top.indexOf(w); if (i > -1) top = top.slice(0, i); } const labels = []; const patterns = [/Exclusive Offer\\s*\\$\\s*[\\d,.]+/ig, /Unlock Offer/ig, /Special Offer!?/ig, /Buy\\s+.{1,80}?(?:off|Free|!)/ig, /\\d+\\s*for\\s*\\d+%\\s*off/ig, /Extra\\s*\\d+%\\s*OFF!?/ig]; for (const re of patterns) { const matches = top.match(re) || []; matches.forEach(v => labels.push(v.replace(/\\s+/g, ' ').trim())); } return Array.from(new Set(labels)).join(' | '); })()",
            "attribute": "text",
            "isJs": true
          },
          {
            "name": "merchant",
            "selector": "(() => { const meta = document.querySelector('meta[name=\"store_name\"], meta[property=\"store_name\"]')?.content; if (meta) return meta.trim(); const text = ROW.innerText.replace(/\\s+/g, ' ').trim(); let m = text.match(/Sold by\\s+(.+?)\\s+(?:This product|Qty|Add to Cart|$)/i); if (m) return m[1].trim(); m = text.match(/About\\s+(.+?)\\s+T\\s*&\\s*C/i); return m ? m[1].trim() : ''; })()",
            "attribute": "text",
            "isJs": true
          },
          {
            "name": "packing",
            "selector": "(() => { const text = ROW.innerText.replace(/\\s+/g, ' ').trim(); const m = text.match(/Packing Spec\\s+(.+?)\\s+Country of Origin/i) || text.match(/Packing Spec\\s+(.+?)\\s+Description/i); return m ? m[1].trim() : ''; })()",
            "attribute": "text",
            "isJs": true
          },
          {
            "name": "salesnumber",
            "selector": "(() => { const text = ROW.innerText.replace(/\\s+/g, ' ').trim(); const m = text.match(/([\\d,]+\\+?\\s*Sold)/i); return m ? m[1] : ''; })()",
            "attribute": "text",
            "isJs": true
          },
          {
            "name": "reviewnumber",
            "selector": "(() => { const text = ROW.innerText.replace(/\\s+/g, ' ').trim(); let m = text.match(/\\(([\\d,]+)\\s*Customer Review\\(s\\)\\)/i); if (m) return '(' + m[1] + ')'; m = text.match(/([\\d,]+)\\s*Review\\(s\\)/i); return m ? '(' + m[1] + ')' : ''; })()",
            "attribute": "text",
            "isJs": true
          },
          {
            "name": "express",
            "selector": "(() => { const text = ROW.innerText.replace(/\\s+/g, ' ').trim(); const m = text.match(/((?:Next Day|Same Day|\\d+-Hour|\\d+-Day|[0-9]+ Day)\\s+Delivery)/i); return m ? m[1] : ''; })()",
            "attribute": "text",
            "isJs": true
          },
          {
            "name": "toMacau",
            "selector": "(() => { const text = ROW.innerText.replace(/\\s+/g, ' ').trim(); return /Ship to Macau|To MO/i.test(text) ? 'Ship to Macau' : ''; })()",
            "attribute": "text",
            "isJs": true
          }
        ]
      }
    },
    {
      "block_id": "loop-continue-1",
      "block_type": "process",
      "title": "Loop Continue",
      "description": "Continue multi-input loop",
      "position_x": 1920,
      "position_y": 220,
      "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": "wait-for-element-1",
      "to_connector_id": "left"
    },
    {
      "from_block_id": "wait-for-element-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": "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": 1400,
      "height": 296,
      "z_index": 20,
      "data": {
        "memberBlockIds": [
          "navigate-1",
          "wait-for-page-load-1",
          "wait-for-element-1",
          "sleep-1"
        ]
      }
    },
    {
      "id": "group-extract",
      "element_type": "group",
      "title": "Data Extraction",
      "color": "#42be65",
      "position_x": 1488,
      "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": 1848,
      "position_y": 116,
      "width": 380,
      "height": 296,
      "z_index": 20,
      "data": {
        "memberBlockIds": [
          "loop-continue-1"
        ]
      }
    },
    {
      "id": "note-overview",
      "element_type": "note",
      "title": "Overview",
      "content": "Best-effort HKTVmall product scraper equivalent to the Octoparse HKTVmall template. The original keyword search-results selector was not available during autonomous execution, so this version scrapes the provided HKTVmall Dettol product detail URLs directly and extracts the same kind of fields: input keyword, title, URL, price, RSP/original price, image URL, promotion label, merchant, packing, sold count, review count, delivery label, and Macau shipping flag. Navigation uses a predefined URL list with loop-continue and appends all product rows to hktvmall-scraper.csv. Add more HKTVmall product URLs to navigate.urls to expand coverage.",
      "color": "#f1c21b",
      "position_x": 80,
      "position_y": 20,
      "width": 480,
      "height": 160,
      "z_index": 22,
      "data": {}
    },
    {
      "id": "note-block-navigate-1",
      "element_type": "note",
      "title": "Note: Navigate",
      "content": "Multi-URL loop over 2 pages. Pair with loop-continue at the end of each iteration.",
      "color": "#ee5396",
      "position_x": 320,
      "position_y": 200,
      "width": 328,
      "height": 107,
      "z_index": 22,
      "data": {
        "block_id": "navigate-1"
      }
    },
    {
      "id": "note-block-structured-export-1",
      "element_type": "note",
      "title": "Note: Structured Export",
      "content": "Structured export with JS columns (input_keyword, title, title_url, price, RSP). These selectors are fragile — update if the site layout changes.",
      "color": "#ee5396",
      "position_x": 1760,
      "position_y": 200,
      "width": 340,
      "height": 128,
      "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": 2120,
      "position_y": 200,
      "width": 340,
      "height": 123,
      "z_index": 22,
      "data": {
        "block_id": "loop-continue-1"
      }
    }
  ]
}