Actualizar robot.js

This commit is contained in:
2026-04-06 18:53:38 +00:00
parent a4658d6031
commit 3541e5974a

View File

@@ -295,26 +295,18 @@ async function runHomeserve(ownerId, user, pass, gremiosDB) {
});
const page = await browser.newPage();
try {
console.log("🌍 [HomeServe] Entrando a la web...");
console.log("🌍 [HomeServe] Entrando...");
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"]')) {
console.log("🔑 [HomeServe] Formulario detectado. Rellenando datos...");
await page.fill('input[name="CODIGO"]', user);
await page.fill('input[type="password"]', pass);
await page.keyboard.press('Enter');
console.log("⌨️ [HomeServe] Pulsando Enter...");
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 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
const listaConIconos = await page.evaluate(() => {
@@ -338,8 +330,6 @@ async function runHomeserve(ownerId, user, pass, gremiosDB) {
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)
const refs = [...new Set(listaConIconos.map(item => item.ref))];