Actualizar robot.js

This commit is contained in:
2026-04-06 18:58:12 +00:00
parent 157d945b26
commit 4681fd7db6

View File

@@ -295,18 +295,26 @@ async function runHomeserve(ownerId, user, pass, gremiosDB) {
}); });
const page = await browser.newPage(); const page = await browser.newPage();
try { try {
console.log("🌍 [HomeServe] Entrando..."); console.log("🌍 [HomeServe] Entrando a la web...");
await gotoWithRetry(page, 'https://www.clientes.homeserve.es/cgi-bin/fccgi.exe?w3exec=PROF_PASS'); await gotoWithRetry(page, 'https://www.clientes.homeserve.es/cgi-bin/fccgi.exe?w3exec=PROF_PASS');
console.log(`🔎 [HomeServe] URL actual: ${page.url()}`);
if (await page.isVisible('input[name="CODIGO"]')) { if (await page.isVisible('input[name="CODIGO"]')) {
console.log("🔑 [HomeServe] Formulario detectado. Rellenando datos...");
await page.fill('input[name="CODIGO"]', user); await page.fill('input[name="CODIGO"]', user);
await page.fill('input[type="password"]', pass); await page.fill('input[type="password"]', pass);
await page.keyboard.press('Enter'); await page.keyboard.press('Enter');
console.log("⌨️ [HomeServe] Pulsando Enter...");
await page.waitForTimeout(5000); await page.waitForTimeout(5000);
console.log(`👀 [HomeServe] URL tras intentar login: ${page.url()}`);
} else {
console.log("⚠️ [HomeServe] NO se detectó el formulario de login.");
} }
console.log("📋 [HomeServe] Yendo a la lista de servicios...");
await gotoWithRetry(page, 'https://www.clientes.homeserve.es/cgi-bin/fccgi.exe?w3exec=lista_servicios_total'); await gotoWithRetry(page, 'https://www.clientes.homeserve.es/cgi-bin/fccgi.exe?w3exec=lista_servicios_total');
await page.waitForTimeout(3000); await page.waitForTimeout(3000);
console.log(`📍 [HomeServe] URL de la lista cargada: ${page.url()}`);
// 🛑 NUEVO: Ahora extraemos la referencia Y LOS ICONOS de la misma pasada // 🛑 NUEVO: Ahora extraemos la referencia Y LOS ICONOS de la misma pasada
const listaConIconos = await page.evaluate(() => { const listaConIconos = await page.evaluate(() => {
@@ -330,6 +338,8 @@ async function runHomeserve(ownerId, user, pass, gremiosDB) {
return results; return results;
}); });
console.log(`📊 [HomeServe] Total de filas válidas extraídas de la tabla: ${listaConIconos.length}`);
// Sacamos solo los números para la escoba (syncAndArchive) // Sacamos solo los números para la escoba (syncAndArchive)
const refs = [...new Set(listaConIconos.map(item => item.ref))]; const refs = [...new Set(listaConIconos.map(item => item.ref))];