feat: 飞书知识库工具集:wiki 节点 CRUD、早报/总结/踩坑写入(修复 wiki_delete 支持 bitable 节点删除)

This commit is contained in:
NightStar
2026-08-03 18:49:35 +08:00
commit 4105f8521a
13 changed files with 1030 additions and 0 deletions
+37
View File
@@ -0,0 +1,37 @@
#!/usr/bin/env python3
"""列出知识库节点,可选指定父节点"""
import json, sys, os
import subprocess
SPACE_ID = os.environ.get('FEISHU_SPACE_ID', '7664817589230570761')
def get_token():
r = subprocess.run(['python3', os.path.join(os.path.dirname(__file__), 'init_token.py')],
capture_output=True, text=True)
td = json.loads(r.stdout)
return td['token']
def list_nodes(parent_token=None):
import requests
token = get_token()
h = {'Authorization': 'Bearer ' + token, 'Content-Type': 'application/json'}
url = f'https://open.feishu.cn/open-apis/wiki/v2/spaces/{SPACE_ID}/nodes'
params = {}
if parent_token:
params['parent_node_token'] = parent_token
r = requests.get(url, params=params, headers=h)
data = r.json()
if data.get('code') != 0:
raise Exception(f"API error: {data.get('msg')}")
return data['data']['items']
if __name__ == '__main__':
parent = sys.argv[1] if len(sys.argv) > 1 else None
try:
nodes = list_nodes(parent)
print(json.dumps(nodes, indent=2, ensure_ascii=False))
except Exception as e:
print(f'Error: {e}', file=sys.stderr)
sys.exit(1)