{
  "version": "1.0.0",
  "exported_at": "2026-06-01T00:00:00.000Z",
  "project": {
    "name": "Google Flights Scraper",
    "description": "Scrapes Google Flights flight-result data equivalent to the Octoparse template: trip type, section title, departure, destination, outbound date, return date, time, airline, duration, airports, stops, and price. Default search is Barcelona to Madrid, round trip, departing 2026-09-28 and returning 2026-10-02. Pagination/navigation strategy: the workflow opens Google Flights, handles common consent prompts, checks for and repeatedly clicks any “More flights / Show more flights / Ver más vuelos” button, then normalizes all currently loaded flight cards into stable scraper rows before CSV export. Google may show CAPTCHA or anti-bot checks; if blocked, the normalization step creates a diagnostic row rather than silently failing.",
    "color": "bg-[#4589ff]",
    "template_id": "ai-generated"
  },
  "blocks": [
    {
      "block_id": "set-window-size-1",
      "block_type": "process",
      "title": "Set Window Size",
      "description": "Set browser window dimensions",
      "position_x": 120,
      "position_y": 220,
      "config": {
        "width": 1920,
        "height": 1080
      }
    },
    {
      "block_id": "navigate-1",
      "block_type": "process",
      "title": "Navigate",
      "description": "Go to a URL",
      "position_x": 456,
      "position_y": 220,
      "config": {
        "url": "https://www.google.com/travel/flights/search?hl=en&gl=US&curr=USD&q=Round%20trip%20flights%20from%20Barcelona%20to%20Madrid%20departing%202026-09-28%20returning%202026-10-02",
        "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": 792,
      "position_y": 220,
      "config": {
        "timeout": 45
      }
    },
    {
      "block_id": "inject-javascript-1",
      "block_type": "process",
      "title": "Inject JavaScript",
      "description": "Run custom JavaScript on the page",
      "position_x": 1128,
      "position_y": 220,
      "config": {
        "jsCode": "(()=>{const labels=['accept all','accept','i agree','agree','aceptar todo','aceptar','acepto','estoy de acuerdo','tout accepter','alle akzeptieren'];const els=Array.from(document.querySelectorAll('button,input[type=\"submit\"],div[role=\"button\"],span[role=\"button\"],a[role=\"button\"]'));let clicked=0;for(const el of els){const txt=((el.innerText||el.textContent||el.value||el.getAttribute('aria-label')||'')+'').trim().toLowerCase();if(labels.some(l=>txt===l||txt.includes(l))){try{el.click();clicked++;break;}catch(e){}}}for(const sel of ['#L2AGLb','#introAgreeButton','button[aria-label=\"Accept all\"]']){const el=document.querySelector(sel);if(el){try{el.click();clicked++;}catch(e){}}}return 'consent clicks: '+clicked;})()",
        "waitForCompletion": true,
        "timeout": 10
      }
    },
    {
      "block_id": "sleep-1",
      "block_type": "process",
      "title": "Sleep",
      "description": "Wait for specified time",
      "position_x": 1464,
      "position_y": 220,
      "config": {
        "duration": 10
      }
    },
    {
      "block_id": "inject-javascript-2",
      "block_type": "process",
      "title": "Inject JavaScript",
      "description": "Run custom JavaScript on the page",
      "position_x": 1800,
      "position_y": 220,
      "config": {
        "jsCode": "(()=>{window.scrollTo(0,Math.min(document.body.scrollHeight,1200));return 'scrolled to trigger Google Flights lazy rendering';})()",
        "waitForCompletion": true,
        "timeout": 10
      }
    },
    {
      "block_id": "sleep-2",
      "block_type": "process",
      "title": "Sleep",
      "description": "Wait for specified time",
      "position_x": 2136,
      "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": 2472,
      "position_y": 220,
      "config": {
        "selector": "body",
        "timeout": 30,
        "visible": true
      }
    },
    {
      "block_id": "element-exists-1",
      "block_type": "process",
      "title": "Element Exists",
      "description": "Check if element exists",
      "position_x": 2808,
      "position_y": 220,
      "config": {
        "selector": "//button[contains(translate(normalize-space(.),'ABCDEFGHIJKLMNOPQRSTUVWXYZÁÉÍÓÚ','abcdefghijklmnopqrstuvwxyzáéíóú'),'more flights') or contains(translate(normalize-space(.),'ABCDEFGHIJKLMNOPQRSTUVWXYZÁÉÍÓÚ','abcdefghijklmnopqrstuvwxyzáéíóú'),'show more') or contains(translate(normalize-space(.),'ABCDEFGHIJKLMNOPQRSTUVWXYZÁÉÍÓÚ','abcdefghijklmnopqrstuvwxyzáéíóú'),'ver más vuelos') or contains(translate(normalize-space(.),'ABCDEFGHIJKLMNOPQRSTUVWXYZÁÉÍÓÚ','abcdefghijklmnopqrstuvwxyzáéíóú'),'mostrar más vuelos') or contains(translate(normalize-space(.),'ABCDEFGHIJKLMNOPQRSTUVWXYZÁÉÍÓÚ','abcdefghijklmnopqrstuvwxyzáéíóú'),'otros vuelos')]"
      }
    },
    {
      "block_id": "click-1",
      "block_type": "process",
      "title": "Click",
      "description": "Click on element",
      "position_x": 3144,
      "position_y": 520,
      "config": {
        "selector": "//button[contains(translate(normalize-space(.),'ABCDEFGHIJKLMNOPQRSTUVWXYZÁÉÍÓÚ','abcdefghijklmnopqrstuvwxyzáéíóú'),'more flights') or contains(translate(normalize-space(.),'ABCDEFGHIJKLMNOPQRSTUVWXYZÁÉÍÓÚ','abcdefghijklmnopqrstuvwxyzáéíóú'),'show more') or contains(translate(normalize-space(.),'ABCDEFGHIJKLMNOPQRSTUVWXYZÁÉÍÓÚ','abcdefghijklmnopqrstuvwxyzáéíóú'),'ver más vuelos') or contains(translate(normalize-space(.),'ABCDEFGHIJKLMNOPQRSTUVWXYZÁÉÍÓÚ','abcdefghijklmnopqrstuvwxyzáéíóú'),'mostrar más vuelos') or contains(translate(normalize-space(.),'ABCDEFGHIJKLMNOPQRSTUVWXYZÁÉÍÓÚ','abcdefghijklmnopqrstuvwxyzáéíóú'),'otros vuelos')]",
        "timeout": 15
      }
    },
    {
      "block_id": "sleep-3",
      "block_type": "process",
      "title": "Sleep",
      "description": "Wait for specified time",
      "position_x": 3480,
      "position_y": 520,
      "config": {
        "duration": 4
      }
    },
    {
      "block_id": "inject-javascript-3",
      "block_type": "process",
      "title": "Inject JavaScript",
      "description": "Run custom JavaScript on the page",
      "position_x": 2808,
      "position_y": 520,
      "config": {
        "jsCode": "(()=>{const old=document.getElementById('uscraper-flight-normalized');if(old)old.remove();const container=document.createElement('div');container.id='uscraper-flight-normalized';container.style.cssText='position:absolute;left:-9999px;top:0;width:1px;height:1px;overflow:visible;';document.body.appendChild(container);const norm=s=>(s||'').replace(/\\s+/g,' ').trim();const linesOf=t=>(t||'').split('\\n').map(norm).filter(Boolean);const bodyText=document.body.innerText||'';const route={tipo:'Round trip',partida:'Barcelona',destino:'Madrid',fechaIda:'2026-09-28',fechaVuelta:'2026-10-02'};const selectors=['li.pIav2d','div.pIav2d','div[role=\"listitem\"]','li','div[jscontroller]'];const nodes=Array.from(document.querySelectorAll(selectors.join(',')));const records=[];const seen=new Set();function parseCandidate(el){const text=el.innerText||'';if(text.length<20||text.length>2500)return null;if(!/\\d{1,2}:\\d{2}/.test(text))return null;if(!/(\\$|US\\$|USD|€|£|\\b\\d+\\s*(?:h|hr|hrs|hour|hours)\\b|stop|stops|escala|escalas|nonstop|direct)/i.test(text))return null;const lines=linesOf(text);const timeMatch=text.match(/\\b\\d{1,2}:\\d{2}\\s*(?:AM|PM)?\\s*[–—-]\\s*\\d{1,2}:\\d{2}\\s*(?:AM|PM)?/i);const allTimes=text.match(/\\b\\d{1,2}:\\d{2}\\s*(?:AM|PM)?\\b/gi)||[];const hora=timeMatch?norm(timeMatch[0]):(allTimes.length>=2?allTimes[0]+' - '+allTimes[1]:(allTimes[0]||''));const priceMatch=text.match(/(?:US\\$|USD|\\$|€|£)\\s?[\\d,.]+|[\\d,.]+\\s?(?:US\\$|USD|€|£)/i);const durationMatch=text.match(/\\b\\d+\\s*(?:h|hr|hrs|hour|hours)\\s*(?:\\d+\\s*(?:min|m))?/i)||text.match(/\\b\\d+\\s*h\\s*\\d*\\s*min?\\b/i);const airportMatch=text.match(/\\b[A-Z]{3}\\s*[–—-]\\s*[A-Z]{3}\\b/);const codes=Array.from(new Set((text.match(/\\b[A-Z]{3}\\b/g)||[]).filter(x=>!['USD','CO2'].includes(x))));const stopLine=lines.find(s=>/nonstop|direct|sin escalas|\\d+\\s*(stop|stops|escala|escalas)/i.test(s))||'';let airline='';for(const s of lines){if(!/(\\d{1,2}:\\d{2}|US\\$|USD|\\$|€|£|\\b\\d+\\s*(h|hr|hrs|min)|stop|stops|escala|escalas|nonstop|direct|[A-Z]{3}\\s*[–—-]\\s*[A-Z]{3}|emission|CO2|round trip|one-way|select|price)/i.test(s)&&/[A-Za-zÁÉÍÓÚáéíóú]/.test(s)){airline=s;break;}}let title='';let p=el;for(let i=0;p&&i<8;i++,p=p.parentElement){const h=p.querySelector&&p.querySelector('h2,h3,[role=\"heading\"]');if(h&&norm(h.textContent)){title=norm(h.textContent);break;}}const aeropuertos=airportMatch?airportMatch[0].replace(/[–—]/g,'-'):(codes.length>=2?codes[0]+' - '+codes[1]:'BCN - MAD');const rec={tipo:route.tipo,titulo:title||'Google Flights result',partida:route.partida,destino:route.destino,fechaIda:route.fechaIda,fechaVuelta:route.fechaVuelta,hora,airline,duracion:durationMatch?norm(durationMatch[0]):'',aeropuertos,escala:stopLine,precio:priceMatch?norm(priceMatch[0]):''};if(!rec.hora&&!rec.precio&&!rec.airline)return null;return rec;}for(const el of nodes){const rec=parseCandidate(el);if(!rec)continue;const key=[rec.hora,rec.airline,rec.duracion,rec.precio,rec.escala].join('|');if(seen.has(key))continue;seen.add(key);records.push(rec);if(records.length>=80)break;}if(records.length===0){records.push({tipo:route.tipo,titulo:/captcha|unusual traffic|verify/i.test(bodyText)?'Blocked by Google verification or CAPTCHA':'No Google Flights result cards detected',partida:route.partida,destino:route.destino,fechaIda:route.fechaIda,fechaVuelta:route.fechaVuelta,hora:'',airline:'',duracion:'',aeropuertos:'BCN - MAD',escala:'',precio:''});}for(const r of records){const row=document.createElement('div');row.className='uscraper-flight-row';row.textContent=[r.hora,r.airline,r.duracion,r.aeropuertos,r.escala,r.precio].filter(Boolean).join(' | ')||r.titulo;row.setAttribute('data-tipo',r.tipo||'');row.setAttribute('data-titulo',r.titulo||'');row.setAttribute('data-partida',r.partida||'');row.setAttribute('data-destino',r.destino||'');row.setAttribute('data-fecha-ida',r.fechaIda||'');row.setAttribute('data-fecha-vuelta',r.fechaVuelta||'');row.setAttribute('data-hora',r.hora||'');row.setAttribute('data-airline',r.airline||'');row.setAttribute('data-duracion',r.duracion||'');row.setAttribute('data-aeropuertos',r.aeropuertos||'');row.setAttribute('data-escala',r.escala||'');row.setAttribute('data-precio',r.precio||'');container.appendChild(row);}return 'normalized flight rows: '+records.length;})()",
        "waitForCompletion": true,
        "timeout": 20
      }
    },
    {
      "block_id": "wait-for-element-2",
      "block_type": "process",
      "title": "Wait for Element",
      "description": "Wait until element appears",
      "position_x": 3312,
      "position_y": 800,
      "config": {
        "selector": ".uscraper-flight-row",
        "timeout": 10,
        "visible": true
      }
    },
    {
      "block_id": "structured-export-1",
      "block_type": "process",
      "title": "Structured Export",
      "description": "Export data with custom columns",
      "position_x": 3648,
      "position_y": 800,
      "config": {
        "rowSelector": ".uscraper-flight-row",
        "fileName": "google_vuelos_scraper.csv",
        "saveLocation": "C:\\Users\\theskd\\Documents\\UScraper\\templates",
        "includeHeaders": true,
        "fileMode": "create",
        "columns": [
          {
            "name": "tipo_de_viaje",
            "selector": "",
            "attribute": "data-tipo"
          },
          {
            "name": "titulo",
            "selector": "",
            "attribute": "data-titulo"
          },
          {
            "name": "partida",
            "selector": "",
            "attribute": "data-partida"
          },
          {
            "name": "destino",
            "selector": "",
            "attribute": "data-destino"
          },
          {
            "name": "fecha_ida",
            "selector": "",
            "attribute": "data-fecha-ida"
          },
          {
            "name": "fecha_vuelta",
            "selector": "",
            "attribute": "data-fecha-vuelta"
          },
          {
            "name": "hora",
            "selector": "",
            "attribute": "data-hora"
          },
          {
            "name": "areolinea",
            "selector": "",
            "attribute": "data-airline"
          },
          {
            "name": "durancion",
            "selector": "",
            "attribute": "data-duracion"
          },
          {
            "name": "aeropuertos",
            "selector": "",
            "attribute": "data-aeropuertos"
          },
          {
            "name": "escala",
            "selector": "",
            "attribute": "data-escala"
          },
          {
            "name": "precio",
            "selector": "",
            "attribute": "data-precio"
          }
        ]
      }
    },
    {
      "block_id": "end-1",
      "block_type": "output",
      "title": "End",
      "description": "Terminate execution flow",
      "position_x": 3984,
      "position_y": 800,
      "config": {}
    }
  ],
  "connections": [
    {
      "from_block_id": "set-window-size-1",
      "from_connector_id": "right",
      "to_block_id": "navigate-1",
      "to_connector_id": "left"
    },
    {
      "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": "inject-javascript-2",
      "to_connector_id": "left"
    },
    {
      "from_block_id": "inject-javascript-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-1",
      "to_connector_id": "left"
    },
    {
      "from_block_id": "wait-for-element-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": "sleep-3",
      "to_connector_id": "left"
    },
    {
      "from_block_id": "sleep-3",
      "from_connector_id": "right",
      "to_block_id": "element-exists-1",
      "to_connector_id": "left"
    },
    {
      "from_block_id": "element-exists-1",
      "from_connector_id": "false",
      "to_block_id": "inject-javascript-3",
      "to_connector_id": "left"
    },
    {
      "from_block_id": "inject-javascript-3",
      "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": "structured-export-1",
      "to_connector_id": "left"
    },
    {
      "from_block_id": "structured-export-1",
      "from_connector_id": "right",
      "to_block_id": "end-1",
      "to_connector_id": "left"
    }
  ],
  "canvas_elements": [
    {
      "id": "group-entry",
      "element_type": "group",
      "title": "Entry & Setup",
      "color": "#4589ff",
      "position_x": 48,
      "position_y": 116,
      "width": 380,
      "height": 296,
      "z_index": 20,
      "data": {
        "memberBlockIds": [
          "set-window-size-1"
        ]
      }
    },
    {
      "id": "group-load",
      "element_type": "group",
      "title": "Page Load",
      "color": "#08bdba",
      "position_x": 384,
      "position_y": 116,
      "width": 3344,
      "height": 876,
      "z_index": 20,
      "data": {
        "memberBlockIds": [
          "navigate-1",
          "wait-for-page-load-1",
          "sleep-1",
          "sleep-2",
          "wait-for-element-1",
          "sleep-3",
          "wait-for-element-2"
        ]
      }
    },
    {
      "id": "group-interaction",
      "element_type": "group",
      "title": "Interaction",
      "color": "#a56eff",
      "position_x": 1056,
      "position_y": 116,
      "width": 2000,
      "height": 596,
      "z_index": 20,
      "data": {
        "memberBlockIds": [
          "inject-javascript-1",
          "inject-javascript-2",
          "inject-javascript-3"
        ]
      }
    },
    {
      "id": "group-pagination",
      "element_type": "group",
      "title": "Pagination Loop",
      "color": "#ff832b",
      "position_x": 2736,
      "position_y": 116,
      "width": 656,
      "height": 596,
      "z_index": 20,
      "data": {
        "memberBlockIds": [
          "element-exists-1",
          "click-1"
        ]
      }
    },
    {
      "id": "group-extract",
      "element_type": "group",
      "title": "Data Extraction",
      "color": "#42be65",
      "position_x": 3576,
      "position_y": 696,
      "width": 380,
      "height": 296,
      "z_index": 20,
      "data": {
        "memberBlockIds": [
          "structured-export-1"
        ]
      }
    },
    {
      "id": "group-control",
      "element_type": "group",
      "title": "Control Flow",
      "color": "#8d8d8d",
      "position_x": 3912,
      "position_y": 696,
      "width": 380,
      "height": 296,
      "z_index": 20,
      "data": {
        "memberBlockIds": [
          "end-1"
        ]
      }
    },
    {
      "id": "note-overview",
      "element_type": "note",
      "title": "Overview",
      "content": "Scrapes Google Flights flight-result data equivalent to the Octoparse template: trip type, section title, departure, destination, outbound date, return date, time, airline, duration, airports, stops, and price. Default search is Barcelona to Madrid, round trip, departing 2026-09-28 and returning 2026-10-02. Pagination/navigation strategy: the workflow opens Google Flights, handles common consent prompts, checks for and repeatedly clicks any “More flights / Show more flights / Ver más vuelos” button, then normalizes all currently loaded flight cards into stable scraper rows before CSV export. Google may show CAPTCHA or anti-bot checks; if blocked, the normalization step creates a diagnostic row rather than silently failing.",
      "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: `(()=>{const labels=['accept all','accept','i agree','agree','aceptar todo','aceptar','acepto','estoy...` 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 `//button[contains(translate(normalize-space(.),'ABCDEFGHIJKLMNOPQRSTUVWXYZÁÉÍÓÚ','abcdefghijklmnopqrstuvwxyzáéíóú'),'mor`. True / False branches control which path runs next. Keep enough space between branches so both connector lines are visible.",
      "color": "#ee5396",
      "position_x": 3008,
      "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": "Uses XPath `//button[contains(translate(normalize-space(.),'ABCDEFGHIJKLMNOPQRSTUVWXYZÁÉÍÓÚ','abcdefghijklmnopqr`. XPath breaks easily if DOM structure changes.",
      "color": "#ee5396",
      "position_x": 3344,
      "position_y": 500,
      "width": 340,
      "height": 133,
      "z_index": 22,
      "data": {
        "block_id": "click-1"
      }
    },
    {
      "id": "note-block-inject-javascript-3",
      "element_type": "note",
      "title": "Note: Inject JavaScript",
      "content": "Runs custom JavaScript in the page: `(()=>{const old=document.getElementById('uscraper-flight-normalized');if(old)old.remove();const cont...` Verify in browser if results are empty.",
      "color": "#ee5396",
      "position_x": 3008,
      "position_y": 500,
      "width": 340,
      "height": 140,
      "z_index": 22,
      "data": {
        "block_id": "inject-javascript-3"
      }
    },
    {
      "id": "note-block-structured-export-1",
      "element_type": "note",
      "title": "Note: Structured Export",
      "content": "Extracts rows matching `.uscraper-flight-row`. Confirm row count > 0 before running at scale.",
      "color": "#ee5396",
      "position_x": 3848,
      "position_y": 780,
      "width": 340,
      "height": 111,
      "z_index": 22,
      "data": {
        "block_id": "structured-export-1"
      }
    }
  ]
}