【问题标题】:Connect to page with table Confluence with Python使用 Python 连接到带有表格的页面 Confluence
【发布时间】:2016-09-13 10:35:49
【问题描述】:
【问题讨论】:
标签:
python-2.7
confluence
confluence-rest-api
【解决方案1】:
您可以使用 confluenca api 获取页面 ID
from atlassian import Confluence
space = '~MYSPACE'
title_parent = 'PARENT_PAGE_ID'
p_id = confluence.get_page_id(space, title_parent)
print(p_id)
title = 'New page'
body = 'This is the body of a new page'
status = confluence.create_page(space, title, body, parent_id=p_id, type='page',
representation='storage')
print(status)
【解决方案2】:
查看 Atlassian 示例 here。要更新您的页面,您需要知道您的页面 ID。
【解决方案3】:
最好提出两个请求。第一个是返回页面 ID 的搜索,而后者将返回其内容。
- 搜索
import requests
url = confluence_host + '/rest/api/content/'
res = requests.get(url=url + 'search',
params={'cql': 'space="TEST" AND title="Page Titile'})
page_id = res.json()['results'][0]['id']
- 获取 HTML
import requests
url = confluence_host + '/rest/api/content/'
page = requests.get(url=url + page_id,
params={'expand': 'body.storage'}).json()
html = page['body']['storage']['value']