Actualizar robot.js
This commit is contained in:
19
robot.js
19
robot.js
@@ -168,17 +168,22 @@ async function runMultiasistencia(ownerId, user, pass, gremiosDB) {
|
||||
console.log(` 👉 Encontrados ${unicosPagina.length} expedientes únicos en la pág. ${paginaActual}.`);
|
||||
unicosPagina.forEach(ref => todosExpedientes.add(ref));
|
||||
|
||||
// 2. BUSCAMOS LA URL DEL BOTÓN "SIGUIENTE"
|
||||
const nextPageUrl = await page.evaluate(() => {
|
||||
// 2. BUSCAMOS Y PULSAMOS EL BOTÓN "SIGUIENTE" DIRECTAMENTE EN EL NAVEGADOR
|
||||
const hasNextPage = await page.evaluate(() => {
|
||||
const links = Array.from(document.querySelectorAll('a.lnkheader'));
|
||||
// Buscamos ignorando si tiene flechitas (>>) o mayúsculas
|
||||
const nextBtn = links.find(a => a.innerText.toLowerCase().includes('siguiente'));
|
||||
return nextBtn ? nextBtn.href : null;
|
||||
if (nextBtn) {
|
||||
nextBtn.click(); // Ejecuta el javascript de la web internamente
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
if (nextPageUrl) {
|
||||
console.log(` ➡️ Botón 'Siguiente' detectado. Navegando a la url...`);
|
||||
await gotoWithRetry(page, nextPageUrl);
|
||||
await page.waitForTimeout(3000);
|
||||
if (hasNextPage) {
|
||||
console.log(` ➡️ Botón 'Siguiente' detectado. Pulsando y esperando a cargar...`);
|
||||
// Le damos 4 segundos a la web para que cargue la nueva página tras el click
|
||||
await page.waitForTimeout(4000);
|
||||
paginaActual++;
|
||||
if(paginaActual > 20) {
|
||||
console.log("⚠️ [Multi] Límite de 20 páginas alcanzado por seguridad.");
|
||||
|
||||
Reference in New Issue
Block a user