【问题标题】:How to use the Confluence API "get_all_pages_from_space"?如何使用 Confluence API “get_all_pages_from_space”?
【发布时间】:2021-09-09 03:13:21
【问题描述】:

我正在尝试使用 Confluence API“get_all_pages_from_space”来检索 Confluence 空间中的所有页面(总共 400 个左右)。

# Get all pages from Space
# content_type can be 'page' or 'blogpost'. Defaults to 'page'
# expand is a comma separated list of properties to expand on the content.
# max limit is 100. For more you have to loop over start values.
confluence.get_all_pages_from_space(space, start=0, limit=100, status=None, expand=None, content_type='page')

此 API (here) 的文档说

最大限制为 100。要获得更多,您必须遍历起始值。

我不知道在我的 Python 代码中循环遍历起始值是什么意思。我使用这个 API 来检索一个空间下的所有页面,但它只返回前 50 个左右的页面。

有人用过这个API吗?请让我知道如何遍历起始值。谢谢!

【问题讨论】:

    标签: python confluence-rest-api


    【解决方案1】:

    有点晚了,但希望仍然可以帮助:

    def get_all_pages(confluence, space):
    start = 0
    limit = 100
    _all_pages = []
    while True:
        pages = confluence.get_all_pages_from_space(space, start, limit, status=None, expand=None, content_type='page')
        _all_pages = _all_pages + pages
        if len(pages) < limit:
            break
        start = start + limit
    return _all_pages
    

    【讨论】:

    • 我想出了一个更笨拙的“while”结构来循环开始值,但是 ``if len(pages)
    猜你喜欢
    • 2016-12-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多