# -*- coding: utf-8 -*-
import json, re, os, io, sys
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding="utf-8")
BASE=os.path.dirname(os.path.abspath(__file__))
t=open(os.path.join(BASE,'index_main.html'),encoding='utf-8').read()
s=t[t.find('const PROGRAMS='):t.find('const CATD=')]
chunks=s.split('{id:"')[1:]
for c in chunks:
    c='{id:"'+c
    sid=re.search(r'\{id:"([^"]+)"',c).group(1)
    sch=re.search(r',s:"([^"]+)"',c).group(1)
    nm=re.search(r',n:"([^"]*)"',c)
    det=re.search(r'url:"([^"]+)"',c)
    if sch in ('nyu','uw','cornell'):
        print(sid,'|',sch,'|',(nm.group(1)[:30] if nm else ''),'|',det.group(1) if det else '')
