# -*- coding: utf-8 -*-
import re, io, sys, os, json, datetime
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding="utf-8")
h = open('index_main.html', encoding='utf-8').read()
p0 = h.index("const PROGRAMS=["); p1 = h.index("const CATD=[")
seg = h[p0:p1]
lvls = re.findall(r'lvl:"([^"]*)"', seg)
from collections import Counter
print("PROGRAMS:", len(lvls), "lvl 分布:", dict(Counter(lvls)))
blocks = re.findall(r'\{id:"([^"]+)"([\s\S]*?)(?=\{id:"|,?\n\];)', seg)
phd=ms=0
for bid, rest in blocks:
    lm=re.search(r'lvl:"([^"]*)"',rest); l=lm.group(1) if lm else ''
    if l in ('d','p'): phd+=1
    elif l=='m': ms+=1
print("博士:", phd, "硕士:", ms)
f=os.stat('index_main.html')
print("bytes:", f.st_size)
print("mtime:", datetime.datetime.fromtimestamp(f.st_mtime).strftime('%Y-%m-%d %H:%M:%S'))
