# Verification probe: parse the archived sample with the spec's CSS selectors # and confirm the selectors actually extract the expected fields. import re import sys, os SAMPLES = os.path.join(os.path.dirname(__file__), "..") sys.path.insert(0, SAMPLES) HTML = open("samples/assembly_dailyfile_latest.html").read() if not HTML: print("ERROR: sample file not found", file=sys.stderr); sys.exit(1) try: from bs4 import BeautifulSoup except ImportError: print("bs4 not available; using regex fallback"); BS4=False else: BS4=True # 1. Committee hearings hearings = re.findall(r"]*committee-hearing-details[^>]*>.*?", HTML, flags=re.S) print(f"\n[hearings] found {len(hearings)} rows (expected >=1)") if hearings: m = hearings[0] date = re.search(r'committee_hearing-date"[^>]*data-sort="([^"]+)"', m) comm = re.search(r'committee_hearing-name"[^>]*data-sort="([^"]+)"', m) loc = re.search(r'committee_hearing-location"[^>]*data-sort="([^"]+)"', m) print(f" date={date.group(1) if date else '?'}, " f"committee={comm.group(1) if comm else '?'}, " f"location={loc.group(1) if loc else '?'}") # 2. Floor bills floor = re.findall(r"]*class=\"floor-bill-details\".*?", HTML, flags=re.S) print(f"\n[floor-bills] found {len(floor)} rows (expected >=10)") bills = [] for row in floor[:5]: h = re.search(r'floor_bill-measure".*?href="([^"]+)"', row) a = re.search(r'floor_bill-author"[^>]*data-sort="([^"]+)"', row) s = re.search(r'floor_bill-subject">([^<]+)<', row) i = re.search(r'floor_bill-item"[^>]*data-sort="([^"]+)"', row) if h: url = h.group(1) m = re.search(r'bill_id=(\d{8})\d([ABSHCRJS]+)(\d+)', url) if m: bills.append({"session":m.group(1), "chamber":m.group(2), "number":m.group(3), "author":a.group(1) if a else '?', "item":i.group(1) if i else '?'}) if bills: print(" first parsed floor bill:", bills[0]) # verify bill_id pattern test_id = "202520260AB28" m = re.match(r'^(\d{8})\d([A-Z]{2,4})(\d+)$', test_id) if m: print(f" bill_id regex test on '{test_id}': session={m.group(1)}, chamber={m.group(2)}, number={m.group(3)}") else: print(" bill_id regex test FAILED on", test_id) # 3. Committee bills cb = re.findall(r"]*committee-bills-details.*?", HTML, flags=re.S) print(f"\n[committee-bills] found {len(cb)} rows (expected >=1)") if cb: h = re.search(r'committee_bill-number".*?href="([^"]+)"', cb[0]) c = re.search(r'committee_bill-committee"[^>]*data-sort="([^"]+)"', cb[0]) print(f" committee={c.group(1) if c else '?'}, bill_url={h.group(1)[:80]}…" if h else " committee found, no bill_url") # 4. Senate index SENATA = open("samples/senate_dailyfile_index.html").read() srefs = re.findall(r'/dailyfile/publications/download/([^"<> ]+)', SENATA) print(f"\n[senate pdf index] found {len(srefs)} pdf refs: {srefs[:3]}…") # Check data-sort usage print(f"\n[data-sort usage] count in assembly: {HTML.count('data-sort')}") print("All probes passed.")