import urllib.request, json

ports = [9222, 9223, 28792]
for port in ports:
    try:
        data = json.loads(urllib.request.urlopen(f'http://localhost:{port}/json', timeout=2).read())
        print(f"端口 {port}: {len(data)} 个页面")
        for p in data:
            print(f"  [{p.get('id','')[:20]}] {p.get('url','no url')[:80]}")
    except Exception as e:
        print(f"端口 {port}: 未占用 ({e})")
