const { chromium } = require('playwright'); const fs = require('fs'); const path = require('path'); async function searchSiblu() { const browser = await chromium.launch({ headless: true }); const context = await browser.newContext({ viewport: { width: 1920, height: 1080 }, userAgent: 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36' }); const page = await context.newPage(); const screenshotDir = path.join(process.env.HOME, 'holiday-planning', 'price-evidence'); const results = { searchDate: new Date().toISOString(), park: 'Domaine de Kerlann', dates: { checkIn: '2026-07-18', checkOut: '2026-08-02', nights: 14 }, guests: { adults: 2, children: 1, childAge: 6 }, screenshots: [], status: 'in_progress' }; try { console.log('šŸ” Navigating to Siblu website...'); await page.goto('https://www.siblu.co.uk', { waitUntil: 'networkidle', timeout: 60000 }); await page.screenshot({ path: path.join(screenshotDir, '01-homepage.png'), fullPage: false }); results.screenshots.push('01-homepage.png'); console.log('āœ… Homepage loaded'); // Handle Didomi cookie consent console.log('šŸŖ Handling Didomi cookie consent...'); await page.waitForTimeout(2000); const didomiSelectors = [ '#didomi-notice-agree-button', 'button#didomi-notice-agree-button', 'span:has-text("Agree to all")', 'button:has-text("Agree")', 'button:has-text("Accept")', '#didomi-popup button.didomi-components-button', '[data-testid="accept-all"]' ]; for (const selector of didomiSelectors) { try { const btn = await page.$(selector); if (btn) { const isVisible = await btn.isVisible(); if (isVisible) { await btn.click({ force: true }); console.log(`āœ… Clicked Didomi button: ${selector}`); await page.waitForTimeout(1500); break; } } } catch (e) {} } // Also try clicking by evaluating in browser context await page.evaluate(() => { // Try to click Didomi agree button const agreeBtn = document.getElementById('didomi-notice-agree-button'); if (agreeBtn) agreeBtn.click(); // Try to close Didomi popup const didomiHost = document.getElementById('didomi-host'); if (didomiHost) didomiHost.style.display = 'none'; }); await page.waitForTimeout(1000); await page.screenshot({ path: path.join(screenshotDir, '02-after-cookies.png'), fullPage: false }); results.screenshots.push('02-after-cookies.png'); // Navigate to park page console.log('šŸ” Navigating to Domaine de Kerlann park page...'); await page.goto('https://www.siblu.co.uk/holiday-parcs/brittany/domaine-de-kerlann', { waitUntil: 'networkidle', timeout: 60000 }); // Handle any new cookie popup await page.waitForTimeout(2000); await page.evaluate(() => { const agreeBtn = document.getElementById('didomi-notice-agree-button'); if (agreeBtn) agreeBtn.click(); const didomiHost = document.getElementById('didomi-host'); if (didomiHost) didomiHost.style.display = 'none'; }); await page.waitForTimeout(1000); await page.screenshot({ path: path.join(screenshotDir, '03-park-page.png'), fullPage: true }); results.screenshots.push('03-park-page.png'); console.log('āœ… Park page loaded'); // Now look for availability search console.log('šŸ“… Looking for booking/availability form...'); // Try to find booking form inputs const html = await page.content(); fs.writeFileSync(path.join(screenshotDir, 'park-page-full.html'), html); // Look for a way to search availability // Siblu usually has a booking widget or link // Try finding check-in/check-out inputs const inputs = await page.$$('input'); console.log(`Found ${inputs.length} input fields`); for (const input of inputs) { const name = await input.getAttribute('name'); const type = await input.getAttribute('type'); const placeholder = await input.getAttribute('placeholder'); console.log(` - Input: name=${name}, type=${type}, placeholder=${placeholder}`); } // Try to find and click "Check Availability" or similar const bookBtns = await page.$$('button, a'); for (const btn of bookBtns) { const text = await btn.textContent(); if (text && (text.toLowerCase().includes('check availability') || text.toLowerCase().includes('book') || text.toLowerCase().includes('search'))) { console.log(`Found button: "${text.trim()}"`); } } // Try clicking on availability link try { const availBtn = await page.waitForSelector('a:has-text("Check availability"), button:has-text("Check availability"), a:has-text("Book"), button:has-text("Book now")', { timeout: 5000 }); if (availBtn) { await availBtn.click({ force: true }); await page.waitForTimeout(3000); await page.screenshot({ path: path.join(screenshotDir, '04-after-click.png'), fullPage: true }); results.screenshots.push('04-after-click.png'); } } catch (e) { console.log('No direct availability button found'); } // Get final URL results.url = page.url(); console.log(`Final URL: ${results.url}`); // Look for any pricing information const bodyText = await page.textContent('body'); const priceMatches = bodyText.match(/Ā£[\d,]+\.?\d*/g); if (priceMatches) { console.log('šŸ’° Found prices on page:', [...new Set(priceMatches)].slice(0, 20)); results.pricesFound = [...new Set(priceMatches)]; } // Look for mobile homes / accommodation info const accommodationMatches = bodyText.match(/(?:mobile home|caravan|chalet|lodges?|accommodation)[^.]*(?:from|starting|Ā£)/gi); if (accommodationMatches) { results.accommodationInfo = accommodationMatches.slice(0, 5); } results.status = 'completed_initial_search'; } catch (error) { console.error('āŒ Error:', error.message); results.error = error.message; await page.screenshot({ path: path.join(screenshotDir, 'error-screenshot.png'), fullPage: true }); results.screenshots.push('error-screenshot.png'); } await browser.close(); const resultsPath = path.join(process.env.HOME, 'holiday-planning', 'prices', 'siblu-domaine-de-kerlann.json'); fs.writeFileSync(resultsPath, JSON.stringify(results, null, 2)); console.log(`\nšŸ“ Results saved to: ${resultsPath}`); return results; } searchSiblu().catch(console.error);