From 3b4a14661cac5432c3475358add06efe388030c6 Mon Sep 17 00:00:00 2001 From: Matthias Hochmeister Date: Sun, 19 Apr 2026 19:37:17 +0200 Subject: [PATCH] fix(sync): use ViewState extraction for Untersuchungen pagination instead of form submit --- sync/src/scraper.ts | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/sync/src/scraper.ts b/sync/src/scraper.ts index 14ac2dc..1063d7c 100644 --- a/sync/src/scraper.ts +++ b/sync/src/scraper.ts @@ -979,15 +979,23 @@ async function scrapeMemberUntersuchungen( return []; } - // Show all rows: select "ALLE", then explicitly submit the form so ASP.NET - // processes the request with its server-generated ViewState. - await selectAlleAnzeige(frame); - const submitBtn = frame.locator('input[type="image"][src*="suchen"]'); - if (await submitBtn.count() > 0) { - await Promise.all([ - frame.waitForNavigation({ waitUntil: 'networkidle', timeout: 15000 }).catch(() => {}), - submitBtn.click(), - ]); + // ASP.NET needs ViewState to properly process anzeige_count. + // Extract it from the loaded page and re-navigate with all params + ALLE. + const formState = await frame.evaluate(() => { + const vs = (document.getElementById('__VIEWSTATE') as HTMLInputElement)?.value ?? ''; + const vsg = (document.getElementById('__VIEWSTATEGENERATOR') as HTMLInputElement)?.value ?? ''; + return { vs, vsg }; + }).catch(() => ({ vs: '', vsg: '' })); + + if (formState.vs) { + const alleUrl = `${BASE_URL}/fdisk/module/mgvw/untersuchungen/UntersuchungenList.aspx` + + `?__VIEWSTATE=${encodeURIComponent(formState.vs)}` + + `&__VIEWSTATEGENERATOR=${encodeURIComponent(formState.vsg)}` + + `&searchdatum=&searchanmerkungen=&searchid_untersuchungsarten=` + + `&searchid_personen=${idPersonen}&searchid_mitgliedschaften=${idMitgliedschaft}` + + `&id_personen=${idPersonen}&id_mitgliedschaften=${idMitgliedschaft}` + + `&anzeige_count=ALLE&offset=0&ordnung=2&orderType=ASC&search=1`; + await frame_goto(frame, alleUrl); } // Try to navigate to history/detail view if available