Confulence提供了非常清晰的RESTful API,直接使用API比confluence_python_cli这个库更方便。
参考文档:https://developer.atlassian.com/server/confluence/confluence-server-rest-api/
CQL参考:https://developer.atlassian.com/server/confluence/cql-field-reference/#created
比如统计某个用户某段时间的文档贡献量:
import requests
from datetime import datetime
def get_confluence_doc_num(user, start_time, end_time=None, page_type='page'):
"""获取某人Confulence文档数量"""
if end_time is None:
end_time = datetime.now().strftime('%Y-%m-%d')
url = f'http://confluence.siku.cn/rest/api/content/search?cql=(creator={user} and type={page_type} ' f'and created >= {start_time} and created < {end_time})&limit=1000'
res = requests.get(url, auth=('用户名', '密码'))
return res.json().get('size')