Some checks failed
ci / ci (22, ubuntu-latest) (push) Has been cancelled
Nuxt 4 + Supabase + Flightics API. Incluye búsqueda de vuelos, inspiraciones, watchlist, tracking de precios y mapa interactivo. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
67 lines
1.8 KiB
JavaScript
67 lines
1.8 KiB
JavaScript
import { chromium } from "playwright";
|
|
import { writeFileSync, appendFileSync } from "fs";
|
|
|
|
const LOG_FILE = "flightics_requests.log";
|
|
writeFileSync(LOG_FILE, `=== Flightics Network Log - ${new Date().toISOString()} ===\n\n`);
|
|
|
|
function log(text) {
|
|
console.log(text);
|
|
appendFileSync(LOG_FILE, text + "\n");
|
|
}
|
|
|
|
const browser = await chromium.launch({ headless: false });
|
|
const context = await browser.newContext();
|
|
const page = await context.newPage();
|
|
|
|
const requests = [];
|
|
|
|
// Interceptar todas las peticiones de red
|
|
page.on("request", (req) => {
|
|
const url = req.url();
|
|
const method = req.method();
|
|
const resourceType = req.resourceType();
|
|
|
|
// Filtrar solo XHR/fetch (las llamadas a APIs)
|
|
if (resourceType === "xhr" || resourceType === "fetch") {
|
|
const entry = {
|
|
method,
|
|
url,
|
|
headers: req.headers(),
|
|
postData: req.postData() || null,
|
|
};
|
|
requests.push(entry);
|
|
log(`\n>>> ${method} ${url}`);
|
|
log(` HEADERS: ${JSON.stringify(req.headers())}`);
|
|
if (entry.postData) {
|
|
log(` BODY: ${entry.postData}`);
|
|
}
|
|
}
|
|
});
|
|
|
|
page.on("response", async (res) => {
|
|
const req = res.request();
|
|
if (req.resourceType() === "xhr" || req.resourceType() === "fetch") {
|
|
const status = res.status();
|
|
const url = res.url();
|
|
log(`<<< ${status} ${url}`);
|
|
try {
|
|
const contentType = res.headers()["content-type"] || "";
|
|
if (contentType.includes("json")) {
|
|
const body = await res.json();
|
|
log(` RESPONSE: ${JSON.stringify(body, null, 2)}`);
|
|
}
|
|
} catch {
|
|
// ignore
|
|
}
|
|
}
|
|
});
|
|
|
|
log("Abriendo Flightics... Navega y busca vuelos manualmente.");
|
|
log("Presiona Ctrl+C cuando termines.\n");
|
|
log(`Log guardado en: ${LOG_FILE}\n`);
|
|
|
|
await page.goto("https://www.flightics.com/");
|
|
|
|
// Esperar a que el usuario interactue y cierre
|
|
await new Promise(() => {});
|