SPB Git forge

spb/vrai-prix

Public

Vrai-Prix — l'évaluation du vrai prix des propriétés résidentielles au Québec.

60commits 1branches 0releases
12.3 MBsize
maindefault branch
17 days agolast push
TypeScript 90.2% JavaScript 3.5% Python 3.4% CSS 1.9% HTML 0.6%
1.9 KB · 53 lines javascript
Raw Blame History
1// Captures d'écran du site en prod pour le README (jetable).2import { chromium } from "playwright";3import { mkdirSync } from "fs";45const OUT = "docs/screenshots";6mkdirSync(OUT, { recursive: true });7const BASE = "https://www.vrai-prix.com";8const FICHE = "/estimation/66023993631880550000000";910const SHOTS = [11  { path: "/", name: "accueil", wait: 2500 },12  { path: FICHE, name: "fiche-estimation", wait: 3500 },13  { path: FICHE, name: "fiche-portrait", wait: 3500, scrollTo: 1800 },14  { path: "/carte", name: "carte", wait: 9000 },15  { path: "/stats", name: "stats", wait: 3200 },16  { path: "/ka", name: "ka-agent", wait: 2500 },17  { path: "/municipalite/gatineau", name: "municipalite", wait: 2000 },18  { path: "/methodologie", name: "methodologie", wait: 2000 },19  { path: "/", name: "accueil-mobile", wait: 2500, mobile: true },20  { path: FICHE, name: "fiche-mobile", wait: 3500, mobile: true },21];2223const browser = await chromium.launch();24for (const s of SHOTS) {25  const ctx = await browser.newContext({26    viewport: s.mobile ? { width: 390, height: 844 } : { width: 1440, height: 900 },27    deviceScaleFactor: 2,28    locale: "fr-CA",29    isMobile: !!s.mobile,30  });31  // masque le bandeau de témoins (consentement déjà donné)32  await ctx.addInitScript(() => {33    try {34      localStorage.setItem(35        "vp-cookie-consent",36        JSON.stringify({ necessary: true, analytics: false, ts: 1755000000000 })37      );38      localStorage.setItem("vp-lang", "fr");39    } catch {}40  });41  const page = await ctx.newPage();42  await page.goto(BASE + s.path, { waitUntil: "networkidle", timeout: 60000 }).catch(() => {});43  await page.waitForTimeout(s.wait);44  if (s.scrollTo) {45    await page.evaluate((y) => window.scrollTo({ top: y, behavior: "instant" }), s.scrollTo);46    await page.waitForTimeout(1200);47  }48  await page.screenshot({ path: `${OUT}/${s.name}.png` });49  console.log("✓", s.name);50  await ctx.close();51}52await browser.close();53