Files
Gloria/check_all_children.py

64 lines
2.0 KiB
Python

"""获取2026.01页面的所有子页面(包括分页)"""
import asyncio
import sys
sys.path.insert(0, '.')
from confluence.client import ConfluenceClient
async def get_all_children():
"""获取所有子页面,处理分页"""
print("=" * 60)
print("🔍 获取2026.01所有子页面(处理分页)")
print("=" * 60)
client = ConfluenceClient()
page_id = "159049201"
try:
# 获取子页面,增加限制
children = await client.get_children(page_id, limit=200)
print(f"\n📄 找到 {len(children)} 个子页面\n")
# 按标题排序
sorted_children = sorted(children, key=lambda x: x.get('title', ''))
# 查找353-360
found_ships = []
for child in sorted_children:
title = child.get('title', '')
child_id = child.get('id', '')
if 'FZ ' in title:
try:
import re
match = re.search(r'FZ\s+(\d+)#', title)
if match:
num = int(match.group(1))
if 350 <= num <= 365:
found_ships.append((num, title, child_id))
except:
pass
if found_ships:
print(f"350-365# 船次列表:\n")
for num, title, child_id in sorted(found_ships):
print(f" {title} (ID: {child_id})")
else:
print("❌ 未找到350-365#范围内的船次")
# 显示最后10条
print(f"\n最后10个子页面:")
print("-" * 60)
for child in sorted_children[-10:]:
print(f" {child.get('title')} (ID: {child.get('id')})")
except Exception as e:
print(f"\n❌ 错误: {e}")
import traceback
traceback.print_exc()
finally:
await client.close()
if __name__ == "__main__":
asyncio.run(get_all_children())