{
  "version": "1.0.0",
  "exported_at": "2026-05-31T18:30:00.000Z",
  "project": {
    "name": "Searchch Lead Scraper",
    "description": "Scrapes Search.ch lead detail pages for Octoparse-equivalent fields: keyword, location code, opening status, title, address, phone, fax, email, website link, information/category text, and detail URL. Navigation strategy: multi-URL loop over Search.ch detail-page URLs using navigate.urls[] + structured-export append + loop-continue. Replace or extend the URLs list with additional Search.ch detail URLs discovered from keyword searches. Cookie consent is dismissed with JavaScript when present. No login is required. Website-link extraction excludes cookie/sponsored/navigation links, and information extraction reads the business category line nearest to the active listing title.",
    "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": 240,
      "config": {
        "urls": [
          "https://search.ch/tel/dinhard/eschlikerstrasse-20/biber-manz-architektur-ag",
          "https://search.ch/tel/winterthur/garnmarkt-1/walser-zumbrunn-waeckerli-architektur-gmbh",
          "https://search.ch/tel/rheinau/austrasse-5/spi-architektur-design"
        ],
        "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": 240,
      "config": {
        "timeout": 30,
        "color": "bg-[#08bdba]"
      }
    },
    {
      "block_id": "inject-javascript-1",
      "block_type": "process",
      "title": "Inject JavaScript",
      "description": "Run JavaScript on the page",
      "position_x": 840,
      "position_y": 240,
      "config": {
        "jsCode": "document.querySelector('#onetrust-accept-btn-handler, button[id*=\"accept\" i]')?.click();",
        "waitForCompletion": true,
        "timeout": 5,
        "color": "bg-[#a56eff]"
      }
    },
    {
      "block_id": "sleep-1",
      "block_type": "process",
      "title": "Sleep",
      "description": "Wait for specified time",
      "position_x": 1200,
      "position_y": 240,
      "config": {
        "duration": 1,
        "color": "bg-[#08bdba]"
      }
    },
    {
      "block_id": "wait-for-element-1",
      "block_type": "process",
      "title": "Wait for Element",
      "description": "Wait until element appears",
      "position_x": 1560,
      "position_y": 240,
      "config": {
        "selector": "h1",
        "timeout": 30,
        "visible": true,
        "color": "bg-[#08bdba]"
      }
    },
    {
      "block_id": "structured-export-1",
      "block_type": "process",
      "title": "Structured Export",
      "description": "Export data with custom columns",
      "position_x": 1920,
      "position_y": 240,
      "config": {
        "rowSelector": "body",
        "fileName": "search-ch-lead-scraper.csv",
        "saveLocation": "C:\\Users\\theskd\\Documents\\UScraper\\templates",
        "includeHeaders": true,
        "fileMode": "append",
        "color": "bg-[#42be65]",
        "columns": [
          {
            "name": "keyword",
            "selector": "(() => 'Architektur')()",
            "attribute": "text",
            "isJs": true
          },
          {
            "name": "ort",
            "selector": "(() => '84')()",
            "attribute": "text",
            "isJs": true
          },
          {
            "name": "ob_oeffnen",
            "selector": "(() => { const text = document.body.innerText || ''; const m = text.match(/\\b(OPEN|CLOSED(?:\\s+UNTIL\\s+(?:TOMORROW\\s+)?[0-9:.]+)?|GESCHLOSSEN(?:\\s+BIS\\s+[0-9:.]+)?|OUVERT|FERMÉ[^\\n]*)/i); return m ? m[0].trim() : ''; })()",
            "attribute": "text",
            "isJs": true
          },
          {
            "name": "title",
            "selector": "(() => { const h1s = Array.from(document.querySelectorAll('h1')).map(h => h.textContent.trim()).filter(Boolean); return h1s.length ? h1s[h1s.length - 1] : ''; })()",
            "attribute": "text",
            "isJs": true
          },
          {
            "name": "address",
            "selector": "(() => { const h1s = Array.from(document.querySelectorAll('h1')).map(h => h.textContent.trim()).filter(Boolean); const title = h1s.length ? h1s[h1s.length - 1] : ''; const lines = (document.body.innerText || '').split(/\\n+/).map(s => s.trim()).filter(Boolean); let i = lines.lastIndexOf(title); if (i < 0) return ''; const out = []; let started = false; for (let j = i + 1; j < lines.length; j++) { const l = lines[j]; if (/^(More|Make an appointment|Contacts|Phone|Fax|E-mail|Directions|Timetable|vCard|Edit|Customer feedback|Web pages|Show on map|Opening hours)$/i.test(l)) break; if (/^(OPEN|CLOSED|GESCHLOSSEN|OUVERT|FERM)/i.test(l)) continue; if (/^(Architectural firm|Interior architecture|General contractor)/i.test(l)) continue; if (!started) { if (/\\d/.test(l) && !/^\\+?\\d[\\d\\s*()-]+$/.test(l) && !/^[0-2]?\\d:[0-5]\\d/.test(l)) started = true; else continue; } out.push(l); if (/\\b\\d{4}\\b/.test(l)) break; } return out.join('\\n'); })()",
            "attribute": "text",
            "isJs": true
          },
          {
            "name": "phone",
            "selector": "(() => { const a = Array.from(document.querySelectorAll('a[href^=\"tel:\"]'))[0]; if (!a) return ''; const raw = a.getAttribute('href').replace(/^tel:/, '').replace(/[^\\d+]/g, ''); if (raw.startsWith('+41') && raw.length >= 12) return '+41 ' + raw.slice(3,5) + ' ' + raw.slice(5,8) + ' ' + raw.slice(8,10) + ' ' + raw.slice(10,12); return (a.textContent || '').trim() || raw; })()",
            "attribute": "text",
            "isJs": true
          },
          {
            "name": "fax",
            "selector": "(() => { const text = document.body.innerText || ''; const m = text.match(/Fax\\s+(\\+41\\s*\\d{2}\\s*\\d{3}\\s*\\d{2}\\s*\\d{2})/i); return m ? m[1].replace(/\\s+/g, ' ').trim() : ''; })()",
            "attribute": "text",
            "isJs": true
          },
          {
            "name": "email",
            "selector": "(() => { const mails = Array.from(new Set(Array.from(document.querySelectorAll('a[href^=\"mailto:\"]')).map(a => decodeURIComponent(a.getAttribute('href').replace(/^mailto:/, '').split('?')[0])).filter(Boolean))); if (mails.length) return mails.join('; '); const text = document.body.innerText || ''; const found = text.match(/[A-Z0-9._%+-]+@[A-Z0-9.-]+\\.[A-Z]{2,}/ig) || []; return Array.from(new Set(found)).join('; '); })()",
            "attribute": "text",
            "isJs": true
          },
          {
            "name": "link",
            "selector": "(() => { const direct = document.querySelector('a.sl-icon-website[href]'); if (direct) return direct.href; const badHosts = /(search\\.ch|login\\.search\\.ch|booking-widget|localsearch\\.ch|onetrust\\.com|cookielaw\\.org)/i; const anchors = Array.from(document.querySelectorAll('a[href]')); const candidate = anchors.find(a => { const txt = (a.textContent || '').trim(); try { const u = new URL(a.href, location.href); if (!/^https?:$/.test(u.protocol)) return false; if (badHosts.test(u.hostname)) return false; if (a.href.includes('/digitalone')) return false; if (/^(Directions|Timetable|vCard|Edit|Make an appointment|Details|More|privacy statement|terms and conditions of use)$/i.test(txt)) return false; return txt.toLowerCase() === 'web' || /^[\\w.-]+\\.[a-z]{2,}/i.test(txt) || a.classList.contains('sl-icon-website'); } catch (e) { return false; } }); return candidate ? candidate.href : ''; })()",
            "attribute": "text",
            "isJs": true
          },
          {
            "name": "informationen",
            "selector": "(() => { const h1s = Array.from(document.querySelectorAll('h1')).map(h => h.textContent.trim()).filter(Boolean); const title = h1s.length ? h1s[h1s.length - 1] : ''; const lines = (document.body.innerText || '').split(/\\n+/).map(s => s.replace(/\\s+/g, ' ').trim()).filter(Boolean); const i = lines.lastIndexOf(title); let category = ''; if (i >= 0) { for (let j = i - 1; j >= Math.max(0, i - 10); j--) { let l = lines[j]; l = l.replace(/\\b(?:OPEN|CLOSED(?: UNTIL (?:TOMORROW )?[0-9:.]+)?|GESCHLOSSEN(?: BIS [0-9:.]+)?|OUVERT|FERMÉ[^,]*)\\b/ig, '').replace(/\\s+/g, ' ').trim(); if (!l) continue; if (/Sponsored|Your sponsored link here|Details|Make an appointment|vCard|Rate now|Customer feedback|Extended search/i.test(l)) continue; if (/\\b(GmbH|AG|SA|Ltd|Inc)\\b/i.test(l)) continue; if (l.length > 90) continue; if (/(Architectural firm|Interior architecture|General contractor|Architekt|Architektur|Baukultur)/i.test(l)) { category = l.replace(/\\s*,\\s*/g, '; ').trim(); break; } } } const text = document.body.innerText || ''; const hours = text.match(/Opening hours\\s+([^\\n]+)/i); const parts = []; if (category) parts.push(category); if (hours) parts.push('Opening hours: ' + hours[1].replace(/\\s+/g, ' ').trim()); return parts.join(' | '); })()",
            "attribute": "text",
            "isJs": true
          },
          {
            "name": "detail_url",
            "selector": "(() => location.href)()",
            "attribute": "text",
            "isJs": true
          }
        ]
      }
    },
    {
      "block_id": "loop-continue-1",
      "block_type": "process",
      "title": "Loop Continue",
      "description": "Continue multi-input loop",
      "position_x": 2280,
      "position_y": 240,
      "config": {
        "color": "bg-[#ff832b]"
      }
    }
  ],
  "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": "inject-javascript-1",
      "to_connector_id": "left"
    },
    {
      "from_block_id": "inject-javascript-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": "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": 136,
      "width": 1760,
      "height": 296,
      "z_index": 20,
      "data": {
        "memberBlockIds": [
          "navigate-1",
          "wait-for-page-load-1",
          "sleep-1",
          "wait-for-element-1"
        ]
      }
    },
    {
      "id": "group-interaction",
      "element_type": "group",
      "title": "Interaction",
      "color": "#a56eff",
      "position_x": 768,
      "position_y": 136,
      "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": 1848,
      "position_y": 136,
      "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": 2208,
      "position_y": 136,
      "width": 380,
      "height": 296,
      "z_index": 20,
      "data": {
        "memberBlockIds": [
          "loop-continue-1"
        ]
      }
    },
    {
      "id": "note-overview",
      "element_type": "note",
      "title": "Overview",
      "content": "Scrapes Search.ch lead detail pages for Octoparse-equivalent fields: keyword, location code, opening status, title, address, phone, fax, email, website link, information/category text, and detail URL. Navigation strategy: multi-URL loop over Search.ch detail-page URLs using navigate.urls[] + structured-export append + loop-continue. Replace or extend the URLs list with additional Search.ch detail URLs discovered from keyword searches. Cookie consent is dismissed with JavaScript when present. No login is required. Website-link extraction excludes cookie/sponsored/navigation links, and information extraction reads the business category line nearest to the active listing title.",
      "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.querySelector('#onetrust-accept-btn-handler, button[id*=\"accept\" i]')?.click();...` Verify in browser if results are empty.",
      "color": "#ee5396",
      "position_x": 1040,
      "position_y": 220,
      "width": 340,
      "height": 136,
      "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 (keyword, ort, ob_oeffnen, title, address). These selectors are fragile — update if the site layout changes.",
      "color": "#ee5396",
      "position_x": 2120,
      "position_y": 220,
      "width": 340,
      "height": 127,
      "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": 2480,
      "position_y": 220,
      "width": 340,
      "height": 123,
      "z_index": 22,
      "data": {
        "block_id": "loop-continue-1"
      }
    }
  ]
}