#!/usr/bin/env python3
"""Quick check of mingguang gov site structure"""
import sys, re

html = sys.stdin.read()

# Find catIds in various contexts
cats = set(re.findall(r'catId[=:]["\']?(\d+)["\']?', html))
print('catIds:', sorted(cats)[:20])

# Find organIds
orgs = set(re.findall(r'organId[=:]["\']?(\d+)["\']?', html))
print('organIds:', sorted(orgs)[:10])

# Find API/data endpoint patterns
apis = re.findall(r'/chuzhou/[^"\']*', html)
print('Chuzhou APIs:', apis[:5])

# Find if there are any rendered articles
articles = re.findall(r'href="([^"]*content/article[^"]*)"', html)
print('Article links:', articles[:5])

# Check the template scripts
scripts = re.findall(r'<script[^>]*type="text/html"[^>]*id="([^"]+)"', html)
print('Templates:', scripts)

# Find the AJAX data loading configuration
init = re.findall(r'Ls\.url\.get\([^)]+\)', html)
print('URL params:', init[:5])

# Check for specific area
body_sections = re.findall(r'<div[^>]*class="?([^"]*content[^"]*)"?', html)
print('Content divs:', body_sections[:10])

# Print a section of the page with meaningful content
idx = html.find('pageSize')
if idx >= 0:
    print('\n--- Config section ---')
    print(html[max(0,idx-100):idx+300])
