#!/usr/bin/env python3
import requests, re, json

url = "https://www.jinjiang.gov.cn/ztzl/lhzt/lyxx/sthj/"
headers = {"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36"}
r = requests.get(url, timeout=30, headers=headers)
html = r.text

# Extract ALL script content
for m in re.finditer(r'<script[^>]*>([^<]+)</script>', html, re.DOTALL):
    script = m.group(1).strip()
    if len(script) > 100:
        # Look for anything interesting
        for key in ['api','url','ajax','load','page','list','search','ssp','terton','getData','docpuburl','doctitle','docpubdate']:
            if key in script.lower():
                print(f"=== Script snippet containing '{key}' ({len(script)} chars) ===")
                for line in script.split('\n'):
                    if key in line.lower():
                        print(line.strip()[:200])
                print()

print("\n=== Searching for SSP API patterns ===")
for m in re.finditer(r'https?://[^"\']*ssp[^"\']*', html):
    print(m.group())
    
for m in re.finditer(r'https?://[^"\']*/api/[^"\']*', html):
    print(m.group())
