fix: harden parseProfilePage class and program extraction
This commit is contained in:
+4
-2
@@ -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]);
|
||||
|
||||
Reference in New Issue
Block a user