import re

with open('manual_test_upload.html', 'r', encoding='utf-8', errors='replace') as f:
    content = f.read()

print("=== SEARCHING FOR ERROR/ALERT MESSAGES ===")
# Look for common error indicators
patterns = [
    r'<div[^>]*class="[^"]*alert[^"]*"[^>]*>(.*?)</div>',
    r'<div[^>]*class="[^"]*error[^"]*"[^>]*>(.*?)</div>',
    r'<div[^>]*class="[^"]*danger[^"]*"[^>]*>(.*?)</div>',
    r'<p[^>]*class="[^"]*error[^"]*"[^>]*>(.*?)</p>',
    r'<span[^>]*class="[^"]*error[^"]*"[^>]*>(.*?)</span>',
]
found_any = False
for pat in patterns:
    matches = re.findall(pat, content, re.IGNORECASE | re.DOTALL)
    for m in matches:
        clean = re.sub(r'<[^>]+>', '', m).strip()
        if clean:
            print(f"MATCH: {clean[:300]}")
            found_any = True

if not found_any:
    print("No alert/error divs found.")

print("\n=== CHECKING FOR SPECIFIC KEYWORDS ===")
keywords = ['Invalid', 'Error', 'failed', 'rejected', 'limit', 'size', 'quota', 'session', 'expired', 'login', 'unauthorized']
lines = content.split('\n')
for kw in keywords:
    for i, line in enumerate(lines):
        if kw.lower() in line.lower() and '<script' not in line.lower():
            clean = re.sub(r'<[^>]+>', '', line).strip()
            if clean and len(clean) > 3:
                print(f"[{kw}] line {i}: {clean[:200]}")

print("\n=== PAGE TITLE ===")
m = re.search(r'<title>(.*?)</title>', content, re.IGNORECASE)
if m:
    print(m.group(1))

print("\n=== ALL FORM ACTIONS ===")
forms = re.findall(r'<form[^>]*action=["\']([^"\']*)["\'][^>]*>', content, re.IGNORECASE)
for frm in forms:
    print(f"Form action: {frm}")

print("\n=== LOOKING FOR data-* ATTRIBUTES WITH NUMBERS ===")
data_attrs = re.findall(r'data-[\w-]+=["\']\d+["\']', content)
for d in data_attrs[:20]:
    print(d)
