fix: harden parseProfilePage class and program extraction

This commit is contained in:
2026-08-18 15:30:49 +08:00
parent 3c409ea048
commit 94d9b7a879
2 changed files with 24 additions and 2 deletions
+4 -2
View File
@@ -48,7 +48,9 @@
function parseProfilePage(html) {
const result = {};
const bMatch = /<b>([\s\S]*?)<\/b>/i.exec(html);
const h3Match = /<h3[^>]*>([\s\S]*?)<\/h3>/i.exec(html);
const bMatch = (h3Match && /<b>([\s\S]*?)<\/b>/i.exec(h3Match[1])) ||
/<b>([\s\S]*?)<\/b>/i.exec(html);
if (bMatch) result.program = cleanText(bMatch[1]);
const smallMatch = /<small>([\s\S]*?)<\/small>/i.exec(html);
@@ -57,7 +59,7 @@
result.semester = lines[lines.length - 1] || '';
}
const kvRe = /<td[^>]*>([\s\S]*?)<\/td>\s*<td[^>]*class="bold"[^>]*>([\s\S]*?)<\/td>/gi;
const kvRe = /<td[^>]*>([\s\S]*?)<\/td>\s*<td[^>]*class=["'][^"']*\bbold\b[^"']*["'][^>]*>([\s\S]*?)<\/td>/gi;
let m;
while ((m = kvRe.exec(html)) !== null) {
const key = cleanText(m[1]);