# -*- coding: utf-8 -*-
import re, sys, io
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding="utf-8")
idx = open("index_main.html", encoding="utf-8").read()
catd = idx[idx.find("const CATD="):idx.find("const VERIFIED_DETAILS=")]
progs = idx[idx.find("const PROGRAMS="):idx.find("const CATD=")]
keywords = ["Computer Science", "Analytics", "Mechanical Engineering", "Biomedical Engineering",
            "Computational Molecular Biology"]
for kw in keywords:
    rows = re.findall(r'\[[^\]]*"[^"]*'+re.escape(kw)+r'[^"]*"[^\]]*\]', catd)
    print("==", kw, "CATD rows:", len(rows))
    for r in rows[:3]:
        print("  ", r[:300])
    # check if in PROGRAMS
    pin = re.findall(r'en:"[^"]*'+re.escape(kw)+r'[^"]*"', progs)
    print("  in PROGRAMS:", pin[:3])
