This commit is contained in:
Matthias Hochmeister
2026-03-16 12:11:32 +01:00
parent 8d03c13bee
commit 5f329bb5c1
4 changed files with 17 additions and 5 deletions

View File

@@ -905,11 +905,21 @@ async function scrapeMemberFahrgenehmigungen(
const pageData = await frame.evaluate(() => {
const extractCellValue = (cell: Element): string => {
const input = cell.querySelector('input[type="text"], input:not([type])') as HTMLInputElement | null;
if (input) return input.value?.trim() ?? '';
if (input && input.value?.trim()) return input.value.trim();
const sel = cell.querySelector('select') as HTMLSelectElement | null;
if (sel) {
const opt = sel.options[sel.selectedIndex];
return (opt?.text || opt?.value || '').trim();
const idx = sel.selectedIndex;
if (idx >= 0 && sel.options[idx]) {
const t = (sel.options[idx].text || sel.options[idx].value || '').trim();
if (t) return t;
}
if (sel.value?.trim()) return sel.value.trim();
const selectedOpt = sel.querySelector('option[selected]') as HTMLOptionElement | null;
if (selectedOpt) {
const t = (selectedOpt.text || selectedOpt.value || '').trim();
if (t) return t;
}
// fall through to textContent if select is empty
}
const anchor = cell.querySelector('a');
const atitle = anchor?.getAttribute('title')?.trim();