#!/usr/bin/env python3
"""Debug qx detail page."""
import crawl_qx_xxgk as c
import re

url = "https://www.qx.gov.cn/xxgk2222222222222222222222222222222222222/20260720/30310684.html"
html = c.fetch(url)

print("=== Title tag ===")
m = re.search(r"<title>(.*?)</title>", html)
if m: print(repr(m.group(1)))

print("\n=== h1 ===")
m = re.search(r"<h1[^>]*>(.*?)</h1>", html, re.DOTALL)
if m: print(repr(m.group(1)))

print("\n=== Zoom div search ===")
for pattern in ['id="Zoom"', "id='Zoom'", 'id=Zoom', 'id=\"Zoom\"']:
    idx = html.find(pattern)
    if idx != -1:
        print(f"Found '{pattern}' at {idx}: {html[idx:idx+300]}")
        break
else:
    print("No Zoom found")

# Call parser
title, date, content, attrs = c.parse_detail(html, url)
print(f"\n=== Parsed result ===")
print(f"Title: {repr(title)}")
print(f"Date: {repr(date)}")
print(f"Content length: {len(content)}")
print(f"Content: {content[:200]}")
