← back to Watches

thibaut-page-inspector.js

74 lines

#!/usr/bin/env node

const puppeteer = require('puppeteer');

async function inspectPage() {
  const browser = await puppeteer.launch({
    executablePath: '/root/.cache/puppeteer/chrome/linux-145.0.7632.46/chrome-linux64/chrome',
    headless: 'new',
    args: ['--no-sandbox', '--disable-setuid-sandbox', '--disable-dev-shm-usage']
  });

  const page = await browser.newPage();
  await page.setUserAgent('Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36');

  // Login
  console.log('Logging in...');
  await page.goto('https://www.thibautdesign.com/account/login', { waitUntil: 'networkidle2' });
  await page.type('#email', 'info@designerwallcoverings.com');
  await page.type('#password', '*Thibautaccess911*');
  const navP = page.waitForNavigation({ waitUntil: 'networkidle2', timeout: 15000 }).catch(() => {});
  await page.evaluate(() => {
    const forms = document.querySelectorAll('form');
    for (const f of forms) {
      if (f.action.includes('/account/login')) { f.submit(); break; }
    }
  });
  await navP;

  // Go to product page
  const url = 'https://www.thibautdesign.com/products/wallcoverings/AT1401';
  console.log(`\nInspecting: ${url}\n`);
  await page.goto(url, { waitUntil: 'networkidle2' });
  await new Promise(r => setTimeout(r, 1000));

  // Extract all paragraph text
  const data = await page.evaluate(() => {
    const paragraphs = Array.from(document.querySelectorAll('p'))
      .map(p => ({
        className: p.className,
        text: p.textContent.trim(),
        length: p.textContent.trim().length,
        parent: p.parentElement.tagName + (p.parentElement.className ? '.' + p.parentElement.className : '')
      }))
      .filter(p => p.length > 20);

    // Also check meta description
    const metaDesc = document.querySelector('meta[name="description"]');

    // Check for specific product details sections
    const productDetails = document.querySelector('.product-details, .product__description, .product-description');

    return {
      paragraphs,
      metaDescription: metaDesc ? metaDesc.content : null,
      productDetailsHTML: productDetails ? productDetails.innerHTML : null,
      pageTitle: document.title
    };
  });

  console.log('PAGE TITLE:', data.pageTitle);
  console.log('\nMETA DESCRIPTION:', data.metaDescription);
  console.log('\nPRODUCT DETAILS HTML:', data.productDetailsHTML ? data.productDetailsHTML.substring(0, 500) : 'NOT FOUND');
  console.log('\n\nALL PARAGRAPHS (>20 chars):');
  console.log('=' .repeat(80));
  data.paragraphs.forEach((p, i) => {
    console.log(`\n[${i + 1}] Parent: ${p.parent} | Class: "${p.className}" | Length: ${p.length}`);
    console.log(`Text: ${p.text}`);
  });

  await browser.close();
}

inspectPage().catch(console.error);