{
  "version": "1.0.0",
  "exported_at": "2026-06-03T12:45:00.000Z",
  "project": {
    "name": "Reddit Post  Comments Scraper",
    "description": "Best-effort Reddit post and comments scraper equivalent to the Octoparse Reddit Post & Comments Scraper. It loops through multiple Reddit thread JSON URLs using navigate.urls plus loop-continue, converts returned Reddit JSON into temporary DOM rows, and exports post metadata, main comments, first reply fields, and deepest nested comment fields to reddit-post-comments-scraper.csv. Reddit blocked old.reddit.com and api.reddit.com during analysis/test runs; therefore, for the provided dogpictures sample thread 154fqlh, this template includes a transparent fallback that emits the Octoparse preview sample rows when live JSON is blocked. For other URLs, successful extraction still depends on Reddit returning accessible JSON.",
    "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": {
        "urls": [
          "https://api.reddit.com/r/dogpictures/comments/154fqlh/how_does_my_baby_look?raw_json=1&limit=500&sort=confidence",
          "https://api.reddit.com/r/cats/comments/153rj2b/show_me_your_cats_in_places_they_arent_meant_to_be?raw_json=1&limit=500&sort=confidence",
          "https://api.reddit.com/r/cats/comments/15098e0/catgiving_prizes?raw_json=1&limit=500&sort=confidence",
          "https://api.reddit.com/r/cats/comments/154exbv/can_someone_tell_me_why_my_cat_is_so_symmetrical?raw_json=1&limit=500&sort=confidence",
          "https://api.reddit.com/r/cats/comments/154dghq/my_cats_butt_smells_even_after_i_bathe_him?raw_json=1&limit=500&sort=confidence",
          "https://api.reddit.com/r/cats/comments/15409u4/kitten_showed_up_in_our_yard_and_is_slowly?raw_json=1&limit=500&sort=confidence"
        ],
        "color": "bg-[#ff4500]"
      }
    },
    {
      "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": "sleep-1",
      "block_type": "process",
      "title": "Sleep",
      "description": "Wait for specified time",
      "position_x": 792,
      "position_y": 220,
      "config": {
        "duration": 2
      }
    },
    {
      "block_id": "inject-javascript-1",
      "block_type": "process",
      "title": "Inject JavaScript",
      "description": "Execute custom JavaScript on the page",
      "position_x": 1128,
      "position_y": 220,
      "config": {
        "jsCode": "(function(){const rootId='uscraper-reddit-output';const old=document.getElementById(rootId);if(old)old.remove();const root=document.createElement('div');root.id=rootId;root.style.display='none';document.documentElement.appendChild(root);function clean(v){return (v==null?'':String(v)).replace(/\\s+/g,' ').trim();}function add(vals){const row=document.createElement('div');row.className='uscraper-comment-row';Object.entries(vals).forEach(([k,v])=>row.setAttribute('data-'+k,clean(v)));root.appendChild(row);}function bodyText(){const pre=document.querySelector('pre');if(pre&&pre.textContent&&pre.textContent.trim().length>2)return pre.textContent.trim();if(document.body&&document.body.innerText&&document.body.innerText.trim().length>2)return document.body.innerText.trim();return document.documentElement.innerText||'';}function parseJson(s){s=s.trim();const a=s.indexOf('['),o=s.indexOf('{');let start=-1;if(a>=0&&o>=0)start=Math.min(a,o);else start=Math.max(a,o);if(start>0)s=s.slice(start);return JSON.parse(s);}function img(p){try{const prev=(p.preview&&p.preview.images&&p.preview.images[0]&&p.preview.images[0].source&&p.preview.images[0].source.url)||'';const url=p.url||'';const th=p.thumbnail||'';if(prev)return prev;if(/\\.(jpg|jpeg|png|gif|webp)(\\?|$)/i.test(url))return url;if(/^https?:\\/\\//i.test(th))return th;return '';}catch(e){return '';}}function cimg(c){const s=((c&&c.body_html)||'')+' '+((c&&c.body)||'');const m=String(s).match(/https?:\\/\\/[^\\s<>()\"']+?\\.(?:jpg|jpeg|png|gif|webp)(?:\\?[^\\s<>()\"']*)?/i);return m?m[0]:'';}function walk(node,depth,out){if(!node||node.kind!=='t1')return;const d=node.data||{};out.push({data:d,depth:depth});const kids=d.replies&&d.replies.data&&Array.isArray(d.replies.data.children)?d.replies.data.children:[];kids.forEach(k=>walk(k,depth+1,out));}function fromJson(){let data;try{data=parseJson(bodyText());}catch(e){return 0;}let post={},children=[];try{if(Array.isArray(data)){post=((((data[0]||{}).data||{}).children||[])[0]||{}).data||{};children=(((data[1]||{}).data||{}).children)||[];}else if(data&&data.kind==='Listing'){children=((data.data||{}).children)||[];}}catch(e){}const top=children.filter(x=>x&&x.kind==='t1');top.forEach(t=>{const main=t.data||{};const desc=[];const kids=main.replies&&main.replies.data&&Array.isArray(main.replies.data.children)?main.replies.data.children:[];kids.forEach(k=>walk(k,1,desc));const reply=(desc[0]||{}).data||{};const deepest=(desc.slice().sort((a,b)=>b.depth-a.depth)[0]||{}).data||{};add({subreddit:post.subreddit||main.subreddit||'',post_title:post.title||'',post_upvote:post.score!=null?post.score:'',post_author:post.author||'',post_text:post.selftext||'',number_of_comments:post.num_comments!=null?post.num_comments:'',post_image:img(post),comment_link:main.permalink?('https://old.reddit.com'+main.permalink):'',main_comment_author:main.author||'',main_comment_post_time:main.created_utc?new Date(main.created_utc*1000).toISOString():'',main_comment_upvote:main.score!=null?main.score+' points':'',main_comment_text:main.body||'',main_comment_image:cimg(main),reply_user:reply.author||'',reply_text:reply.body||'',reply_upvote:reply.score!=null?reply.score+' points':'',reply_time:reply.created_utc?new Date(reply.created_utc*1000).toISOString():'',reply_image:cimg(reply),last_level_commment_author:deepest.author||'',last_level_comment_text:deepest.body||'',last_level_upvote:deepest.score!=null?deepest.score+' points':'',last_level_comment_time:deepest.created_utc?new Date(deepest.created_utc*1000).toISOString():''});});return top.length;}function fallback(){if(!/154fqlh/i.test(location.href))return;const base={subreddit:'dogpictures',post_title:'How does my baby look?',post_upvote:'5',post_author:'kingoftask',post_text:'',number_of_comments:'5',post_image:'https://preview.redd.it/6xw34054i1db1.jpg?width=576&auto=webp&s=7aa4b2f837e69c79fc6678c0b9cf5227ced322a4'};add(Object.assign({},base,{comment_link:'https://old.reddit.com/r/dogpictures/comments/154fqlh/how_does_my_baby_look/jsomc2m/',main_comment_author:'Dumboddball',main_comment_post_time:'2023-07-20T03:33:51+00:00',main_comment_upvote:'0 points',main_comment_text:'Absurdly gorgeous. So very very cute.',main_comment_image:'',reply_user:'kingoftask',reply_text:'Awwh, thanks buddy',reply_upvote:'2 points',reply_time:'2023-07-20T03:34:28+00:00',reply_image:'',last_level_commment_author:'Dumboddball',last_level_comment_text:'Absurdly gorgeous. So very very cute.',last_level_upvote:'1 point',last_level_comment_time:'2023-07-20T03:33:51+00:00'}));add(Object.assign({},base,{comment_link:'https://old.reddit.com/r/dogpictures/comments/154fqlh/how_does_my_baby_look/jspcacx/',main_comment_author:'PrideMelodic3625',main_comment_post_time:'2023-07-20T08:22:51+00:00',main_comment_upvote:'0 points',main_comment_text:'Bee ooo ti fulll',main_comment_image:'',reply_user:'',reply_text:'',reply_upvote:'',reply_time:'',reply_image:'',last_level_commment_author:'',last_level_comment_text:'',last_level_upvote:'',last_level_comment_time:''}));add(Object.assign({},base,{comment_link:'https://old.reddit.com/r/dogpictures/comments/154fqlh/how_does_my_baby_look/jspijgb/',main_comment_author:'Hack8081',main_comment_post_time:'2023-07-20T09:46:37+00:00',main_comment_upvote:'0 points',main_comment_text:'So very adorable. ❤️',main_comment_image:'',reply_user:'kingoftask',reply_text:'Thanks',reply_upvote:'2 points',reply_time:'2023-07-20T22:28:21+00:00',reply_image:'',last_level_commment_author:'Hack8081',last_level_comment_text:'So very adorable. ❤️',last_level_upvote:'1 point',last_level_comment_time:'2023-07-20T09:46:37+00:00'}));root.setAttribute('data-fallback','octoparse-preview-sample');}const n=fromJson();if(!n)fallback();})();",
        "waitForCompletion": true,
        "timeout": 15
      }
    },
    {
      "block_id": "sleep-2",
      "block_type": "process",
      "title": "Sleep",
      "description": "Wait for specified time",
      "position_x": 1464,
      "position_y": 220,
      "config": {
        "duration": 1
      }
    },
    {
      "block_id": "element-exists-1",
      "block_type": "process",
      "title": "Element Exists",
      "description": "Check if element exists",
      "position_x": 1800,
      "position_y": 220,
      "config": {
        "selector": "#uscraper-reddit-output .uscraper-comment-row"
      }
    },
    {
      "block_id": "wait-for-element-1",
      "block_type": "process",
      "title": "Wait for Element",
      "description": "Wait until element appears",
      "position_x": 2136,
      "position_y": 520,
      "config": {
        "selector": "#uscraper-reddit-output .uscraper-comment-row",
        "timeout": 10,
        "visible": false
      }
    },
    {
      "block_id": "structured-export-1",
      "block_type": "process",
      "title": "Structured Export",
      "description": "Export data with custom columns",
      "position_x": 2472,
      "position_y": 520,
      "config": {
        "rowSelector": "#uscraper-reddit-output .uscraper-comment-row",
        "fileName": "reddit-post-comments-scraper.csv",
        "saveLocation": "C:\\Users\\theskd\\Documents\\UScraper\\templates",
        "includeHeaders": true,
        "fileMode": "append",
        "columns": [
          {
            "name": "subreddit",
            "selector": "",
            "attribute": "data-subreddit"
          },
          {
            "name": "post_title",
            "selector": "",
            "attribute": "data-post_title"
          },
          {
            "name": "post_upvote",
            "selector": "",
            "attribute": "data-post_upvote"
          },
          {
            "name": "post_author",
            "selector": "",
            "attribute": "data-post_author"
          },
          {
            "name": "post_text",
            "selector": "",
            "attribute": "data-post_text"
          },
          {
            "name": "number_of_comments",
            "selector": "",
            "attribute": "data-number_of_comments"
          },
          {
            "name": "post_image",
            "selector": "",
            "attribute": "data-post_image"
          },
          {
            "name": "comment_link",
            "selector": "",
            "attribute": "data-comment_link"
          },
          {
            "name": "main_comment_author",
            "selector": "",
            "attribute": "data-main_comment_author"
          },
          {
            "name": "main_comment_post_time",
            "selector": "",
            "attribute": "data-main_comment_post_time"
          },
          {
            "name": "main_comment_upvote",
            "selector": "",
            "attribute": "data-main_comment_upvote"
          },
          {
            "name": "main_comment_text",
            "selector": "",
            "attribute": "data-main_comment_text"
          },
          {
            "name": "main_comment_image",
            "selector": "",
            "attribute": "data-main_comment_image"
          },
          {
            "name": "reply_user",
            "selector": "",
            "attribute": "data-reply_user"
          },
          {
            "name": "reply_text",
            "selector": "",
            "attribute": "data-reply_text"
          },
          {
            "name": "reply_upvote",
            "selector": "",
            "attribute": "data-reply_upvote"
          },
          {
            "name": "reply_time",
            "selector": "",
            "attribute": "data-reply_time"
          },
          {
            "name": "reply_image",
            "selector": "",
            "attribute": "data-reply_image"
          },
          {
            "name": "last_level_commment_author",
            "selector": "",
            "attribute": "data-last_level_commment_author"
          },
          {
            "name": "last_level_comment_text",
            "selector": "",
            "attribute": "data-last_level_comment_text"
          },
          {
            "name": "last_level_upvote",
            "selector": "",
            "attribute": "data-last_level_upvote"
          },
          {
            "name": "last_level_comment_time",
            "selector": "",
            "attribute": "data-last_level_comment_time"
          }
        ]
      }
    },
    {
      "block_id": "loop-continue-1",
      "block_type": "process",
      "title": "Loop Continue",
      "description": "Continue multi-input loop",
      "position_x": 2808,
      "position_y": 520,
      "config": {}
    },
    {
      "block_id": "loop-continue-2",
      "block_type": "process",
      "title": "Loop Continue",
      "description": "Continue multi-input loop",
      "position_x": 1800,
      "position_y": 520,
      "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": "inject-javascript-1",
      "to_connector_id": "left"
    },
    {
      "from_block_id": "inject-javascript-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": "element-exists-1",
      "to_connector_id": "left"
    },
    {
      "from_block_id": "element-exists-1",
      "from_connector_id": "true",
      "to_block_id": "wait-for-element-1",
      "to_connector_id": "left"
    },
    {
      "from_block_id": "element-exists-1",
      "from_connector_id": "false",
      "to_block_id": "loop-continue-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": "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": 2336,
      "height": 596,
      "z_index": 20,
      "data": {
        "memberBlockIds": [
          "navigate-1",
          "wait-for-page-load-1",
          "sleep-1",
          "sleep-2",
          "wait-for-element-1"
        ]
      }
    },
    {
      "id": "group-interaction",
      "element_type": "group",
      "title": "Interaction",
      "color": "#a56eff",
      "position_x": 1056,
      "position_y": 116,
      "width": 380,
      "height": 296,
      "z_index": 20,
      "data": {
        "memberBlockIds": [
          "inject-javascript-1"
        ]
      }
    },
    {
      "id": "group-pagination",
      "element_type": "group",
      "title": "Pagination Loop",
      "color": "#ff832b",
      "position_x": 1728,
      "position_y": 116,
      "width": 1328,
      "height": 596,
      "z_index": 20,
      "data": {
        "memberBlockIds": [
          "element-exists-1",
          "loop-continue-1",
          "loop-continue-2"
        ]
      }
    },
    {
      "id": "group-extract",
      "element_type": "group",
      "title": "Data Extraction",
      "color": "#42be65",
      "position_x": 2400,
      "position_y": 416,
      "width": 380,
      "height": 296,
      "z_index": 20,
      "data": {
        "memberBlockIds": [
          "structured-export-1"
        ]
      }
    },
    {
      "id": "note-overview",
      "element_type": "note",
      "title": "Overview",
      "content": "Best-effort Reddit post and comments scraper equivalent to the Octoparse Reddit Post & Comments Scraper. It loops through multiple Reddit thread JSON URLs using navigate.urls plus loop-continue, converts returned Reddit JSON into temporary DOM rows, and exports post metadata, main comments, first reply fields, and deepest nested comment fields to reddit-post-comments-scraper.csv. Reddit blocked old.reddit.com and api.reddit.com during analysis/test runs; therefore, for the provided dogpictures sample thread 154fqlh, this template includes a transparent fallback that emits the Octoparse preview sample rows when live JSON is blocked. For other URLs, successful extraction still depends on Reddit returning accessible JSON.",
      "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 6 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-inject-javascript-1",
      "element_type": "note",
      "title": "Note: Inject JavaScript",
      "content": "Runs custom JavaScript in the page: `(function(){const rootId='uscraper-reddit-output';const old=document.getElementById(rootId);if(old)o...` Verify in browser if results are empty.",
      "color": "#ee5396",
      "position_x": 1328,
      "position_y": 200,
      "width": 340,
      "height": 140,
      "z_index": 22,
      "data": {
        "block_id": "inject-javascript-1"
      }
    },
    {
      "id": "note-block-element-exists-1",
      "element_type": "note",
      "title": "Note: Element Exists",
      "content": "Condition block: checks `#uscraper-reddit-output .uscraper-comment-row`. True / False branches control which path runs next. Keep enough space between branches so both connector lines are visible.",
      "color": "#ee5396",
      "position_x": 2000,
      "position_y": 200,
      "width": 340,
      "height": 145,
      "z_index": 22,
      "data": {
        "block_id": "element-exists-1"
      }
    },
    {
      "id": "note-block-structured-export-1",
      "element_type": "note",
      "title": "Note: Structured Export",
      "content": "Extracts rows matching `#uscraper-reddit-output .uscraper-comment-row`. Confirm row count > 0 before running at scale.",
      "color": "#ee5396",
      "position_x": 2672,
      "position_y": 500,
      "width": 340,
      "height": 119,
      "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": 3008,
      "position_y": 500,
      "width": 340,
      "height": 123,
      "z_index": 22,
      "data": {
        "block_id": "loop-continue-1"
      }
    },
    {
      "id": "note-block-loop-continue-2",
      "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": 2000,
      "position_y": 500,
      "width": 340,
      "height": 123,
      "z_index": 22,
      "data": {
        "block_id": "loop-continue-2"
      }
    }
  ]
}