59 lines
1.9 KiB
Python
59 lines
1.9 KiB
Python
"""获取指定Confluence页面的详细内容"""
|
|
import asyncio
|
|
import sys
|
|
sys.path.insert(0, '.')
|
|
|
|
from confluence.client import ConfluenceClient
|
|
from confluence.parser import DataParser
|
|
|
|
async def check_specific_page():
|
|
"""检查用户提供的页面"""
|
|
print("=" * 60)
|
|
print("🔍 检查页面: 161628587")
|
|
print("=" * 60)
|
|
|
|
client = ConfluenceClient()
|
|
page_id = "161628587"
|
|
|
|
try:
|
|
# 获取页面基本信息
|
|
page_info = await client.get_page(page_id)
|
|
if page_info:
|
|
print(f"\n📄 页面标题: {page_info.get('title', 'N/A')}")
|
|
print(f"🆔 页面ID: {page_info.get('id', 'N/A')}")
|
|
print(f"📅 版本: {page_info.get('version', {}).get('number', 'N/A')}")
|
|
|
|
# 获取页面内容
|
|
html_content = await client.get_page_content(page_id)
|
|
if html_content:
|
|
print(f"\n📃 HTML内容长度: {len(html_content)} 字符")
|
|
|
|
# 解析表格
|
|
df = DataParser.extract_table_data(html_content)
|
|
if df is not None:
|
|
print(f"\n📊 提取的表格: {len(df)} 行 x {len(df.columns)} 列")
|
|
print(f"\n表格内容:")
|
|
print(df.to_string())
|
|
|
|
# 转换为字典
|
|
table_dict = DataParser.dataframe_to_dict(df)
|
|
print(f"\n📋 转换后的字典:")
|
|
for key, value in table_dict.items():
|
|
print(f" {key}: {value}")
|
|
else:
|
|
print("\n⚠️ 未找到表格")
|
|
print(f"\nHTML片段 (前500字符):")
|
|
print(html_content[:500])
|
|
else:
|
|
print("\n❌ 无法获取页面内容")
|
|
|
|
except Exception as e:
|
|
print(f"\n❌ 错误: {e}")
|
|
import traceback
|
|
traceback.print_exc()
|
|
finally:
|
|
await client.close()
|
|
|
|
if __name__ == "__main__":
|
|
asyncio.run(check_specific_page())
|