{
  "version": "1.0.0",
  "exported_at": "2026-06-02T18:45:00.000Z",
  "project": {
    "name": "Foursquare Reviews Scraper by URL",
    "description": "Best-effort Foursquare venue reviews scraper equivalent to the Octoparse 'Foursquare Reviews Scraper (by URL)' template. Uses a multi-URL navigation loop over venue URLs and appends extracted review/tip rows to one CSV. The attached analysis shows Foursquare redirects unauthenticated users to a login page; run this template with an authenticated browser profile/session. If the login wall is detected, that URL is skipped. If authenticated, the template expands visible review/tip content, creates stable hidden rows, and exports Business_URL, Business_name, Price_range, Rating, Rating_count, Telephone, Username, Date, Review, and Upvote.",
    "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://foursquare.com/v/independence-prime/5ae397ff772fbc0037fcc15e",
          "https://foursquare.com/v/north-third-restaurant/419e8900f964a5202f1e1fe3",
          "https://foursquare.com/v/vintage/4a36e19df964a520f69d1fe3",
          "https://foursquare.com/v/white-dog-cafe/55572f56498e1fab8abbb6e5",
          "https://foursquare.com/v/mikes-bbq/5a4d2607fc9e9447dc0ca118",
          "https://foursquare.com/v/millers-ale-house--philadelphia/5480e64e498ebc7397d9e68c"
        ],
        "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": "sleep-1",
      "block_type": "process",
      "title": "Sleep",
      "description": "Wait for specified time",
      "position_x": 792,
      "position_y": 220,
      "config": {
        "duration": 3
      }
    },
    {
      "block_id": "text-contains-1",
      "block_type": "process",
      "title": "Text Contains",
      "description": "Check if page contains text",
      "position_x": 1128,
      "position_y": 220,
      "config": {
        "selector": "body",
        "text": "Log in to Foursquare",
        "caseSensitive": false
      }
    },
    {
      "block_id": "inject-javascript-1",
      "block_type": "process",
      "title": "Inject JavaScript",
      "description": "Execute custom JavaScript",
      "position_x": 1128,
      "position_y": 520,
      "config": {
        "jsCode": "(async()=>{const sleep=ms=>new Promise(r=>setTimeout(r,ms));const clean=s=>(s||'').replace(/\\s+/g,' ').trim();for(let i=0;i<8;i++){const btn=[...document.querySelectorAll('button,a')].find(e=>/show more|load more|more tips|more reviews|see more/i.test(clean(e.innerText||e.getAttribute('aria-label')||'')));if(!btn)break;btn.click();await sleep(1200);window.scrollTo(0,document.body.scrollHeight);await sleep(800);}const txt=clean(document.body.innerText);const first=(sels,root=document)=>{for(const s of sels){try{const e=root.querySelector(s);if(e){const v=clean(e.innerText||e.textContent||e.getAttribute('content')||e.getAttribute('aria-label'));if(v)return v;}}catch(_){}}return '';};const bodyMatch=r=>{const m=txt.match(r);return m?clean(m[1]||m[0]):'';};const businessName=first(['h1','[data-testid*=\"name\" i]','meta[property=\"og:title\"]'])||bodyMatch(/^([^\\n]{3,80})/);const priceRange=bodyMatch(/\\${1,4}/);const rating=bodyMatch(/\\b([0-9](?:\\.[0-9])?|10(?:\\.0)?)\\s*\\/?\\s*10\\b/)||bodyMatch(/\\b([0-9](?:\\.[0-9])?|10(?:\\.0)?)\\b(?=\\s*(?:rating|rated))/i);const ratingCount=bodyMatch(/([0-9][0-9,]*)\\s+(?:ratings?|reviews?|tips?)/i);const telephone=bodyMatch(/(?:\\+?1[\\s.-]?)?\\(?\\d{3}\\)?[\\s.-]\\d{3}[\\s.-]\\d{4}/);let container=document.querySelector('#uscraper-review-data');if(container)container.remove();container=document.createElement('div');container.id='uscraper-review-data';container.style.display='none';document.body.appendChild(container);const raw=[...document.querySelectorAll('article,[role=\"article\"],li,div')].filter(e=>{const t=clean(e.innerText);if(t.length<35||t.length>1500)return false;if(/Log in to Foursquare|Enter your email or phone/i.test(t))return false;const hints=[e.className||'',e.getAttribute('data-testid')||'',e.getAttribute('aria-label')||'',Object.values(e.dataset||{}).join(' ')].join(' ');const hasHint=/tip|review|comment|feed|post/i.test(hints);const hasDate=/\\b(?:\\d{1,2}\\/\\d{1,2}\\/\\d{2,4}|Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\\b/i.test(t);const hasUser=!!e.querySelector('a[href*=\"/user\"],a[href*=\"/users\"],a[href*=\"/people\"]');return hasHint||hasDate||hasUser;});const candidates=raw.filter(e=>!raw.some(o=>o!==e&&e.contains(o)&&clean(o.innerText).length>30));const seen=new Set();let count=0;const makeRow=(obj)=>{const row=document.createElement('div');row.className='uscraper-review-row';for(const [k,v] of Object.entries(obj)){row.setAttribute('data-'+k,clean(v));}container.appendChild(row);count++;};for(const el of candidates){const t=clean(el.innerText);if(seen.has(t))continue;seen.add(t);const username=first(['a[href*=\"/user\"],a[href*=\"/users\"],a[href*=\"/people\"]','[data-testid*=\"user\" i]','strong','h3'],el);const date=(t.match(/\\b\\d{1,2}\\/\\d{1,2}\\/\\d{2,4}\\b/)||t.match(/\\b(?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)[a-z]*\\s+\\d{1,2},?\\s+\\d{4}\\b/i)||[''])[0];const upvote=((t.match(/([0-9][0-9,]*)\\s*(?:upvotes?|likes?)/i)||[])[1]||'');let parts=[...el.querySelectorAll('p,span,div')].map(x=>clean(x.innerText)).filter(x=>x.length>20&&x.length<700);parts=parts.filter(x=>x!==username&&x!==date&&!/upvotes?|likes?|rating|directions|website|telephone/i.test(x));let review=parts.sort((a,b)=>b.length-a.length)[0]||t;if(username)review=clean(review.replace(username,''));if(date)review=clean(review.replace(date,''));if(upvote)review=clean(review.replace(new RegExp(upvote+'\\\\s*(upvotes?|likes?)','i'),''));if(review.length<10)continue;makeRow({'business-url':location.href,'business-name':businessName,'price-range':priceRange,'rating':rating,'rating-count':ratingCount,'telephone':telephone,'username':username,'date':date,'review':review,'upvote':upvote});}if(count===0&&businessName){makeRow({'business-url':location.href,'business-name':businessName,'price-range':priceRange,'rating':rating,'rating-count':ratingCount,'telephone':telephone,'username':'','date':'','review':'','upvote':''});}return count;})();",
        "waitForCompletion": true,
        "timeout": 30
      }
    },
    {
      "block_id": "wait-for-element-1",
      "block_type": "process",
      "title": "Wait for Element",
      "description": "Wait until element appears",
      "position_x": 1632,
      "position_y": 800,
      "config": {
        "selector": ".uscraper-review-row",
        "timeout": 20,
        "visible": false
      }
    },
    {
      "block_id": "structured-export-1",
      "block_type": "process",
      "title": "Structured Export",
      "description": "Export data with custom columns",
      "position_x": 1968,
      "position_y": 800,
      "config": {
        "rowSelector": ".uscraper-review-row",
        "fileName": "foursquare-reviews-scraper-by-url.csv",
        "saveLocation": "C:\\Users\\theskd\\Documents\\UScraper\\templates",
        "includeHeaders": true,
        "fileMode": "append",
        "columns": [
          {
            "name": "Business_URL",
            "selector": "",
            "attribute": "data-business-url"
          },
          {
            "name": "Business_name",
            "selector": "",
            "attribute": "data-business-name"
          },
          {
            "name": "Price_range",
            "selector": "",
            "attribute": "data-price-range"
          },
          {
            "name": "Rating",
            "selector": "",
            "attribute": "data-rating"
          },
          {
            "name": "Rating_count",
            "selector": "",
            "attribute": "data-rating-count"
          },
          {
            "name": "Telephone",
            "selector": "",
            "attribute": "data-telephone"
          },
          {
            "name": "Username",
            "selector": "",
            "attribute": "data-username"
          },
          {
            "name": "Date",
            "selector": "",
            "attribute": "data-date"
          },
          {
            "name": "Review",
            "selector": "",
            "attribute": "data-review"
          },
          {
            "name": "Upvote",
            "selector": "",
            "attribute": "data-upvote"
          }
        ]
      }
    },
    {
      "block_id": "loop-continue-1",
      "block_type": "process",
      "title": "Loop Continue",
      "description": "Continue multi-input loop",
      "position_x": 1464,
      "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": "text-contains-1",
      "to_connector_id": "left"
    },
    {
      "from_block_id": "text-contains-1",
      "from_connector_id": "true",
      "to_block_id": "loop-continue-1",
      "to_connector_id": "left"
    },
    {
      "from_block_id": "text-contains-1",
      "from_connector_id": "false",
      "to_block_id": "inject-javascript-1",
      "to_connector_id": "left"
    },
    {
      "from_block_id": "inject-javascript-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": "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": 1832,
      "height": 876,
      "z_index": 20,
      "data": {
        "memberBlockIds": [
          "navigate-1",
          "wait-for-page-load-1",
          "sleep-1",
          "wait-for-element-1"
        ]
      }
    },
    {
      "id": "group-pagination",
      "element_type": "group",
      "title": "Pagination Loop",
      "color": "#ff832b",
      "position_x": 1056,
      "position_y": 116,
      "width": 656,
      "height": 596,
      "z_index": 20,
      "data": {
        "memberBlockIds": [
          "text-contains-1",
          "loop-continue-1"
        ]
      }
    },
    {
      "id": "group-interaction",
      "element_type": "group",
      "title": "Interaction",
      "color": "#a56eff",
      "position_x": 1056,
      "position_y": 416,
      "width": 380,
      "height": 296,
      "z_index": 20,
      "data": {
        "memberBlockIds": [
          "inject-javascript-1"
        ]
      }
    },
    {
      "id": "group-extract",
      "element_type": "group",
      "title": "Data Extraction",
      "color": "#42be65",
      "position_x": 1896,
      "position_y": 696,
      "width": 380,
      "height": 296,
      "z_index": 20,
      "data": {
        "memberBlockIds": [
          "structured-export-1"
        ]
      }
    },
    {
      "id": "note-overview",
      "element_type": "note",
      "title": "Overview",
      "content": "Best-effort Foursquare venue reviews scraper equivalent to the Octoparse 'Foursquare Reviews Scraper (by URL)' template. Uses a multi-URL navigation loop over venue URLs and appends extracted review/tip rows to one CSV. The attached analysis shows Foursquare redirects unauthenticated users to a login page; run this template with an authenticated browser profile/session. If the login wall is detected, that URL is skipped. If authenticated, the template expands visible review/tip content, creates stable hidden rows, and exports Business_URL, Business_name, Price_range, Rating, Rating_count, Telephone, Username, Date, Review, and Upvote.",
      "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": 1328,
      "position_y": 200,
      "width": 340,
      "height": 131,
      "z_index": 22,
      "data": {
        "block_id": "text-contains-1"
      }
    },
    {
      "id": "note-block-inject-javascript-1",
      "element_type": "note",
      "title": "Note: Inject JavaScript",
      "content": "Runs custom JavaScript in the page: `(async()=>{const sleep=ms=>new Promise(r=>setTimeout(r,ms));const clean=s=>(s||'').replace(/\\s+/g,' ...` Verify in browser if results are empty.",
      "color": "#ee5396",
      "position_x": 1328,
      "position_y": 500,
      "width": 340,
      "height": 140,
      "z_index": 22,
      "data": {
        "block_id": "inject-javascript-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": 1664,
      "position_y": 500,
      "width": 340,
      "height": 123,
      "z_index": 22,
      "data": {
        "block_id": "loop-continue-1"
      }
    }
  ]
}