{
  "version": "1.0.0",
  "exported_at": "2026-06-03T15:30:00.000Z",
  "project": {
    "name": "Reddit Search Scraper",
    "description": "Scrapes Reddit Old Search results for the keyword in the search URL, defaulting to Octoparse. Extracts keyword, subreddit, title, author, post time, upvotes, comments, and post URL. Uses click-next pagination and appends all pages to reddit-search-scraper.csv. Reddit may return a network-policy block/login/developer-token page; the template detects the common Old Reddit block message and exits cleanly if blocked.",
    "color": "bg-[#ff4500]",
    "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://old.reddit.com/search?q=Octoparse&sort=relevance&t=all",
        "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": "text-contains-1",
      "block_type": "process",
      "title": "Text Contains",
      "description": "Check if text exists",
      "position_x": 792,
      "position_y": 220,
      "config": {
        "selector": "body",
        "text": "whoa there, pardner!",
        "caseSensitive": false
      }
    },
    {
      "block_id": "end-1",
      "block_type": "output",
      "title": "End",
      "description": "Terminate execution flow",
      "position_x": 1128,
      "position_y": 520,
      "config": {}
    },
    {
      "block_id": "wait-for-element-1",
      "block_type": "process",
      "title": "Wait for Element",
      "description": "Wait until element appears",
      "position_x": 792,
      "position_y": 520,
      "config": {
        "selector": ".search-result.search-result-link, .thing.link",
        "timeout": 30,
        "visible": true
      }
    },
    {
      "block_id": "structured-export-1",
      "block_type": "process",
      "title": "Structured Export",
      "description": "Export data with custom columns",
      "position_x": 1296,
      "position_y": 800,
      "config": {
        "rowSelector": ".search-result.search-result-link, .thing.link",
        "fileName": "reddit-search-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('q') || 'Octoparse'; } catch(e) { return 'Octoparse'; } })()",
            "attribute": "text",
            "isJs": true
          },
          {
            "name": "subreddit",
            "selector": "(() => { const raw = (ROW.querySelector('.search-subreddit-link, a.subreddit')?.textContent || ROW.getAttribute('data-subreddit') || '').trim(); if (!raw) return ''; let s = raw; if (s.startsWith('/r/')) s = s.slice(3); if (s.startsWith('r/')) return s; return 'r/' + s; })()",
            "attribute": "text",
            "isJs": true
          },
          {
            "name": "title",
            "selector": "(() => (ROW.querySelector('a.search-title, a.title')?.textContent || '').trim())()",
            "attribute": "text",
            "isJs": true
          },
          {
            "name": "author",
            "selector": "(() => (ROW.querySelector('a.author')?.textContent || ROW.getAttribute('data-author') || '').trim())()",
            "attribute": "text",
            "isJs": true
          },
          {
            "name": "post_time",
            "selector": "(() => { const dt = ROW.querySelector('time')?.getAttribute('datetime'); if (dt) return dt; const ts = ROW.getAttribute('data-timestamp'); return ts ? new Date(Number(ts)).toISOString() : ''; })()",
            "attribute": "text",
            "isJs": true
          },
          {
            "name": "upvotes",
            "selector": "(() => { const txt = (ROW.querySelector('.search-score, .score.unvoted, .score.likes')?.textContent || '').trim(); const m = txt.match(/[-\\d,]+/); return m ? m[0].replace(/,/g, '') : txt; })()",
            "attribute": "text",
            "isJs": true
          },
          {
            "name": "comments",
            "selector": "(() => { const txt = (ROW.querySelector('a.search-comments, a.comments')?.textContent || '').trim(); const m = txt.match(/[-\\d,]+/); return m ? m[0].replace(/,/g, '') : txt; })()",
            "attribute": "text",
            "isJs": true
          },
          {
            "name": "post_url",
            "selector": "(() => { const t = ROW.querySelector('a.search-title, a.title'); const u = t?.href || ROW.getAttribute('data-url') || ROW.querySelector('a.search-comments, a.comments')?.href || ''; try { return u ? new URL(u, window.location.href).href : ''; } catch(e) { return u; } })()",
            "attribute": "text",
            "isJs": true
          }
        ]
      }
    },
    {
      "block_id": "element-exists-1",
      "block_type": "process",
      "title": "Element Exists",
      "description": "Check if element exists",
      "position_x": 1632,
      "position_y": 800,
      "config": {
        "selector": ".nextprev a[rel=\"nofollow next\"], .nextprev a[href*=\"after=\"]"
      }
    },
    {
      "block_id": "end-2",
      "block_type": "output",
      "title": "End",
      "description": "Terminate execution flow",
      "position_x": 1968,
      "position_y": 800,
      "config": {}
    },
    {
      "block_id": "click-1",
      "block_type": "process",
      "title": "Click",
      "description": "Click on element",
      "position_x": 2304,
      "position_y": 800,
      "config": {
        "selector": ".nextprev a[rel=\"nofollow next\"], .nextprev a[href*=\"after=\"]",
        "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": 2640,
      "position_y": 800,
      "config": {
        "timeout": 30
      }
    },
    {
      "block_id": "sleep-1",
      "block_type": "process",
      "title": "Sleep",
      "description": "Wait for specified time",
      "position_x": 2976,
      "position_y": 800,
      "config": {
        "duration": 2
      }
    }
  ],
  "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": "text-contains-1",
      "to_connector_id": "left"
    },
    {
      "from_block_id": "text-contains-1",
      "from_connector_id": "true",
      "to_block_id": "end-1",
      "to_connector_id": "left"
    },
    {
      "from_block_id": "text-contains-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-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-2",
      "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": "text-contains-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": 3176,
      "height": 876,
      "z_index": 20,
      "data": {
        "memberBlockIds": [
          "navigate-1",
          "wait-for-page-load-1",
          "wait-for-element-1",
          "wait-for-page-load-2",
          "sleep-1"
        ]
      }
    },
    {
      "id": "group-pagination",
      "element_type": "group",
      "title": "Pagination Loop",
      "color": "#ff832b",
      "position_x": 720,
      "position_y": 116,
      "width": 1832,
      "height": 876,
      "z_index": 20,
      "data": {
        "memberBlockIds": [
          "text-contains-1",
          "element-exists-1",
          "click-1"
        ]
      }
    },
    {
      "id": "group-control",
      "element_type": "group",
      "title": "Control Flow",
      "color": "#8d8d8d",
      "position_x": 1056,
      "position_y": 416,
      "width": 1160,
      "height": 576,
      "z_index": 20,
      "data": {
        "memberBlockIds": [
          "end-1",
          "end-2"
        ]
      }
    },
    {
      "id": "group-extract",
      "element_type": "group",
      "title": "Data Extraction",
      "color": "#42be65",
      "position_x": 1224,
      "position_y": 696,
      "width": 380,
      "height": 296,
      "z_index": 20,
      "data": {
        "memberBlockIds": [
          "structured-export-1"
        ]
      }
    },
    {
      "id": "note-overview",
      "element_type": "note",
      "title": "Overview",
      "content": "Scrapes Reddit Old Search results for the keyword in the search URL, defaulting to Octoparse. Extracts keyword, subreddit, title, author, post time, upvotes, comments, and post URL. Uses click-next pagination and appends all pages to reddit-search-scraper.csv. Reddit may return a network-policy block/login/developer-token page; the template detects the common Old Reddit block message and exits cleanly if blocked.",
      "color": "#f1c21b",
      "position_x": 80,
      "position_y": 20,
      "width": 480,
      "height": 160,
      "z_index": 22,
      "data": {}
    },
    {
      "id": "note-block-text-contains-1",
      "element_type": "note",
      "title": "Note: Text Contains",
      "content": "Condition block: checks `body`. 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": 131,
      "z_index": 22,
      "data": {
        "block_id": "text-contains-1"
      }
    },
    {
      "id": "note-block-structured-export-1",
      "element_type": "note",
      "title": "Note: Structured Export",
      "content": "Structured export with JS columns (keyword, subreddit, title, author, post_time). These selectors are fragile — update if the site layout changes.",
      "color": "#ee5396",
      "position_x": 1496,
      "position_y": 780,
      "width": 340,
      "height": 128,
      "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 `.nextprev a[rel=\"nofollow next\"], .nextprev a[href*=\"after=\"]`. True / False branches control which path runs next. Keep enough space between branches so both connector lines are visible.",
      "color": "#ee5396",
      "position_x": 1832,
      "position_y": 780,
      "width": 340,
      "height": 150,
      "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": 2504,
      "position_y": 780,
      "width": 316,
      "height": 106,
      "z_index": 22,
      "data": {
        "block_id": "click-1"
      }
    }
  ]
}