{
  "version": "1.0.0",
  "exported_at": "2026-06-02T18:25:00.000Z",
  "project": {
    "name": "Groupon Scraper",
    "description": "Scrapes Groupon listing/search pages for local deals matching sample Pittsburgh keywords, exporting page URL, page number, title, price, address, rating, rating count, detail URL, and current extraction time. The template uses a pre-extraction JavaScript marker to deduplicate visible Groupon deal links, then appends all rows to groupon-scraper.csv. Pagination is handled with a click-Next loop per keyword URL; when no enabled Next control is found, loop-continue advances to the next starting keyword URL. Groupon may show Cloudflare/security verification and may require completing verification in the persistent browser profile before rows are accessible.",
    "color": "bg-[#4589ff]",
    "template_id": "ai-generated"
  },
  "blocks": [
    {
      "block_id": "navigate-1",
      "block_type": "process",
      "title": "Navigate",
      "description": "Go to a URL",
      "position_x": 100,
      "position_y": 220,
      "config": {
        "urls": [
          "https://www.groupon.com/browse/pittsburgh?lat=40.441&lng=-79.996&query=bowling&locale=en_US&page=1",
          "https://www.groupon.com/browse/pittsburgh?lat=40.441&lng=-79.996&query=swimming&locale=en_US&page=1"
        ],
        "color": "bg-[#4589ff]",
        "tags": [
          "groupon",
          "browse",
          "keywords"
        ]
      }
    },
    {
      "block_id": "wait-for-page-load-1",
      "block_type": "process",
      "title": "Wait for Page Load",
      "description": "Wait for page to finish loading",
      "position_x": 460,
      "position_y": 220,
      "config": {
        "timeout": 45
      }
    },
    {
      "block_id": "sleep-1",
      "block_type": "process",
      "title": "Sleep",
      "description": "Wait for specified time",
      "position_x": 820,
      "position_y": 220,
      "config": {
        "duration": 5
      }
    },
    {
      "block_id": "wait-for-element-1",
      "block_type": "process",
      "title": "Wait for Element",
      "description": "Wait until element appears",
      "position_x": 1180,
      "position_y": 220,
      "config": {
        "selector": "a[href*=\"/deals/\"]",
        "timeout": 60,
        "visible": true
      }
    },
    {
      "block_id": "inject-javascript-1",
      "block_type": "process",
      "title": "Inject JavaScript",
      "description": "Execute custom JavaScript",
      "position_x": 1540,
      "position_y": 220,
      "config": {
        "jsCode": "(() => { document.querySelectorAll('[data-uscraper-groupon-row=\"true\"]').forEach(el => { el.removeAttribute('data-uscraper-groupon-row'); el.removeAttribute('data-uscraper-detail-url'); }); const seen = new Set(); const anchors = Array.from(document.querySelectorAll('a[href*=\"/deals/\"]')); for (const a of anchors) { let href = ''; try { href = new URL(a.getAttribute('href'), location.origin).href; } catch (e) { continue; } const url = new URL(href); const key = url.pathname; if (seen.has(key)) continue; const rect = a.getBoundingClientRect(); const text = (a.textContent || '').replace(/\\s+/g, ' ').trim(); const img = a.querySelector('img'); if ((rect.width <= 1 || rect.height <= 1) && !text && !img) continue; if (!/\\/deals\\//.test(url.pathname)) continue; a.setAttribute('data-uscraper-groupon-row', 'true'); a.setAttribute('data-uscraper-detail-url', href); seen.add(key); } return document.querySelectorAll('[data-uscraper-groupon-row=\"true\"]').length; })();",
        "waitForCompletion": true,
        "timeout": 10
      }
    },
    {
      "block_id": "structured-export-1",
      "block_type": "process",
      "title": "Structured Export",
      "description": "Export data with custom columns",
      "position_x": 1900,
      "position_y": 220,
      "config": {
        "rowSelector": "[data-uscraper-groupon-row=\"true\"]",
        "fileName": "groupon-scraper.csv",
        "saveLocation": "C:\\Users\\theskd\\Documents\\UScraper\\templates",
        "includeHeaders": true,
        "fileMode": "append",
        "columns": [
          {
            "name": "web_page_url",
            "selector": "window.location.href",
            "attribute": "text",
            "isJs": true
          },
          {
            "name": "page_number",
            "selector": "new URL(window.location.href).searchParams.get('page') || (document.querySelector('[aria-current=\"page\"], .active')?.textContent || '').trim() || '1'",
            "attribute": "text",
            "isJs": true
          },
          {
            "name": "title",
            "selector": "(() => { const CARD = ROW.closest('[data-testid*=\"deal-card\"], [data-bhw*=\"deal\"], article, li') || ROW.parentElement || ROW; const selectors = ['[data-testid*=\"deal-title\"]', '[data-testid*=\"title\"]', '[class*=\"deal-title\"]', '[class*=\"title\"]', 'h1', 'h2', 'h3']; for (const sel of selectors) { const el = CARD.querySelector(sel); const val = (el?.getAttribute('aria-label') || el?.textContent || '').replace(/\\s+/g, ' ').trim(); if (val && !/^\\$/.test(val) && !/ratings?$/i.test(val) && val.length > 3) return val; } let txt = (ROW.getAttribute('aria-label') || ROW.textContent || CARD.textContent || '').replace(/\\s+/g, ' ').trim(); if (txt.includes('Read More')) txt = txt.split('Read More').pop().trim(); const priceIndex = txt.search(/\\$\\s?\\d/); if (priceIndex > 0) txt = txt.slice(0, priceIndex).trim(); txt = txt.replace(/\\b\\d+(?:\\.\\d)?\\s*(?:stars?|rating).*$/i, '').trim(); return txt; })()",
            "attribute": "text",
            "isJs": true
          },
          {
            "name": "price",
            "selector": "(() => { const CARD = ROW.closest('[data-testid*=\"deal-card\"], [data-bhw*=\"deal\"], article, li') || ROW.parentElement || ROW; const selectors = ['[data-testid*=\"price\"]', '[class*=\"price\"]', '[aria-label*=\"$\"]']; for (const sel of selectors) { const el = CARD.querySelector(sel); const val = (el?.getAttribute('aria-label') || el?.textContent || '').replace(/\\s+/g, ' ').trim(); const m = val.match(/\\$\\s?\\d[\\d,]*(?:\\.\\d{2})?/); if (m) return m[0]; } const m = (CARD.textContent || ROW.textContent || '').match(/\\$\\s?\\d[\\d,]*(?:\\.\\d{2})?/); return m ? m[0] : ''; })()",
            "attribute": "text",
            "isJs": true
          },
          {
            "name": "address",
            "selector": "(() => { const CARD = ROW.closest('[data-testid*=\"deal-card\"], [data-bhw*=\"deal\"], article, li') || ROW.parentElement || ROW; const selectors = ['[data-testid*=\"address\"]', '[data-testid*=\"location\"]', '[data-testid*=\"merchant-location\"]', '[class*=\"address\"]', '[class*=\"location\"]']; for (const sel of selectors) { const el = CARD.querySelector(sel); const val = (el?.textContent || '').replace(/\\s+/g, ' ').trim(); if (val && !/ratings?|reviews?|stars?|\\$\\s?\\d/i.test(val)) return val; } return ''; })()",
            "attribute": "text",
            "isJs": true
          },
          {
            "name": "rating",
            "selector": "(() => { const CARD = ROW.closest('[data-testid*=\"deal-card\"], [data-bhw*=\"deal\"], article, li') || ROW.parentElement || ROW; const selectors = ['[data-testid*=\"rating\"]', '[aria-label*=\"rating\"]', '[aria-label*=\"star\"]', '[class*=\"rating\"]']; for (const sel of selectors) { const el = CARD.querySelector(sel); const val = (el?.getAttribute('aria-label') || el?.textContent || '').replace(/\\s+/g, ' ').trim(); const m = val.match(/\\b([0-5](?:\\.\\d)?)\\b/); if (m) return m[1]; } const txt = (CARD.textContent || ROW.textContent || '').replace(/\\s+/g, ' '); const m = txt.match(/\\b([0-5](?:\\.\\d)?)\\s*(?:stars?|rating|out of)/i); return m ? m[1] : ''; })()",
            "attribute": "text",
            "isJs": true
          },
          {
            "name": "number_of_rating",
            "selector": "(() => { const CARD = ROW.closest('[data-testid*=\"deal-card\"], [data-bhw*=\"deal\"], article, li') || ROW.parentElement || ROW; const txt = (CARD.textContent || ROW.textContent || '').replace(/\\s+/g, ' '); const m = txt.match(/([\\d,]+)\\s*Ratings?/i) || txt.match(/([\\d,]+)\\s*Reviews?/i); return m ? m[1].replace(/,/g, '') + 'Ratings' : ''; })()",
            "attribute": "text",
            "isJs": true
          },
          {
            "name": "detail_page_url",
            "selector": "ROW.getAttribute('data-uscraper-detail-url') || ROW.href || ''",
            "attribute": "text",
            "isJs": true
          },
          {
            "name": "current_time",
            "selector": "(() => { const d = new Date(); const pad = n => String(n).padStart(2, '0'); return `${d.getFullYear()}-${pad(d.getMonth()+1)}-${pad(d.getDate())}-${pad(d.getHours())}:${pad(d.getMinutes())}:${pad(d.getSeconds())}`; })()",
            "attribute": "text",
            "isJs": true
          }
        ]
      }
    },
    {
      "block_id": "element-exists-1",
      "block_type": "process",
      "title": "Element Exists",
      "description": "Check if element exists",
      "position_x": 2260,
      "position_y": 220,
      "config": {
        "selector": "a[rel=\"next\"], a[aria-label=\"Next\"]:not([aria-disabled=\"true\"]):not(.disabled), button[aria-label=\"Next\"]:not([disabled])"
      }
    },
    {
      "block_id": "click-1",
      "block_type": "process",
      "title": "Click",
      "description": "Click on element",
      "position_x": 2260,
      "position_y": 540,
      "config": {
        "selector": "a[rel=\"next\"], a[aria-label=\"Next\"]:not([aria-disabled=\"true\"]):not(.disabled), button[aria-label=\"Next\"]:not([disabled])",
        "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": 2620,
      "position_y": 540,
      "config": {
        "timeout": 45
      }
    },
    {
      "block_id": "sleep-2",
      "block_type": "process",
      "title": "Sleep",
      "description": "Wait for specified time",
      "position_x": 2980,
      "position_y": 540,
      "config": {
        "duration": 3
      }
    },
    {
      "block_id": "wait-for-element-2",
      "block_type": "process",
      "title": "Wait for Element",
      "description": "Wait until element appears",
      "position_x": 3340,
      "position_y": 540,
      "config": {
        "selector": "a[href*=\"/deals/\"]",
        "timeout": 60,
        "visible": true
      }
    },
    {
      "block_id": "inject-javascript-2",
      "block_type": "process",
      "title": "Inject JavaScript",
      "description": "Execute custom JavaScript",
      "position_x": 3700,
      "position_y": 540,
      "config": {
        "jsCode": "(() => { document.querySelectorAll('[data-uscraper-groupon-row=\"true\"]').forEach(el => { el.removeAttribute('data-uscraper-groupon-row'); el.removeAttribute('data-uscraper-detail-url'); }); const seen = new Set(); const anchors = Array.from(document.querySelectorAll('a[href*=\"/deals/\"]')); for (const a of anchors) { let href = ''; try { href = new URL(a.getAttribute('href'), location.origin).href; } catch (e) { continue; } const url = new URL(href); const key = url.pathname; if (seen.has(key)) continue; const rect = a.getBoundingClientRect(); const text = (a.textContent || '').replace(/\\s+/g, ' ').trim(); const img = a.querySelector('img'); if ((rect.width <= 1 || rect.height <= 1) && !text && !img) continue; if (!/\\/deals\\//.test(url.pathname)) continue; a.setAttribute('data-uscraper-groupon-row', 'true'); a.setAttribute('data-uscraper-detail-url', href); seen.add(key); } return document.querySelectorAll('[data-uscraper-groupon-row=\"true\"]').length; })();",
        "waitForCompletion": true,
        "timeout": 10
      }
    },
    {
      "block_id": "loop-continue-1",
      "block_type": "process",
      "title": "Loop Continue",
      "description": "Continue multi-input loop",
      "position_x": 2260,
      "position_y": 860,
      "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": "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": "wait-for-element-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": "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": "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-2",
      "to_connector_id": "left"
    },
    {
      "from_block_id": "sleep-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": "inject-javascript-2",
      "to_connector_id": "left"
    },
    {
      "from_block_id": "inject-javascript-2",
      "from_connector_id": "right",
      "to_block_id": "structured-export-1",
      "to_connector_id": "left"
    },
    {
      "from_block_id": "element-exists-1",
      "from_connector_id": "false",
      "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": 28,
      "position_y": 116,
      "width": 3560,
      "height": 616,
      "z_index": 20,
      "data": {
        "memberBlockIds": [
          "navigate-1",
          "wait-for-page-load-1",
          "sleep-1",
          "wait-for-element-1",
          "wait-for-page-load-2",
          "sleep-2",
          "wait-for-element-2"
        ]
      }
    },
    {
      "id": "group-interaction",
      "element_type": "group",
      "title": "Interaction",
      "color": "#a56eff",
      "position_x": 1468,
      "position_y": 116,
      "width": 2480,
      "height": 616,
      "z_index": 20,
      "data": {
        "memberBlockIds": [
          "inject-javascript-1",
          "inject-javascript-2"
        ]
      }
    },
    {
      "id": "group-extract",
      "element_type": "group",
      "title": "Data Extraction",
      "color": "#42be65",
      "position_x": 1828,
      "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": 2188,
      "position_y": 116,
      "width": 380,
      "height": 936,
      "z_index": 20,
      "data": {
        "memberBlockIds": [
          "element-exists-1",
          "click-1",
          "loop-continue-1"
        ]
      }
    },
    {
      "id": "note-overview",
      "element_type": "note",
      "title": "Overview",
      "content": "Scrapes Groupon listing/search pages for local deals matching sample Pittsburgh keywords, exporting page URL, page number, title, price, address, rating, rating count, detail URL, and current extraction time. The template uses a pre-extraction JavaScript marker to deduplicate visible Groupon deal links, then appends all rows to groupon-scraper.csv. Pagination is handled with a click-Next loop per keyword URL; when no enabled Next control is found, loop-continue advances to the next starting keyword URL. Groupon may show Cloudflare/security verification and may require completing verification in the persistent browser profile before rows are accessible.",
      "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: `(() => { document.querySelectorAll('[data-uscraper-groupon-row=\"true\"]').forEach(el => { el.removeAt...` Verify in browser if results are empty.",
      "color": "#ee5396",
      "position_x": 1740,
      "position_y": 200,
      "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 (web_page_url, page_number, title, price, address). These selectors are fragile — update if the site layout changes.",
      "color": "#ee5396",
      "position_x": 2100,
      "position_y": 200,
      "width": 340,
      "height": 130,
      "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[rel=\"next\"], a[aria-label=\"Next\"]:not([aria-disabled=\"true\"]):not(.disabled), button[aria-label=\"Next\"]:not([disabled]`. True / False branches control which path runs next. Keep enough space between branches so both connector lines are visible.",
      "color": "#ee5396",
      "position_x": 2460,
      "position_y": 200,
      "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": "Pagination click — add waits after this block; the page reloads asynchronously.",
      "color": "#ee5396",
      "position_x": 2460,
      "position_y": 520,
      "width": 316,
      "height": 106,
      "z_index": 22,
      "data": {
        "block_id": "click-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": 2460,
      "position_y": 840,
      "width": 340,
      "height": 123,
      "z_index": 22,
      "data": {
        "block_id": "loop-continue-1"
      }
    }
  ]
}