0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Confluence 공간 전체 페이지 리스트 추출하기

Last updated at Posted at 2021-03-10

main888.png

Confluence 한 공간의 전체 페이지 리스트 추출하는 방법입니다.
https://github.com/atlassian-api/atlassian-python-api 을 활용하였습니다. (:star: 558)

테스트 환경

  • Confluence 7.4.3
  • Python 3.7

사전 설치

$ pip install atlassian-python-api

코드

get_all_pages_from_space() 함수로는 최대 500개 까지의 페이지만 추출 됩니다.
API 호출 시 Pagination(페이지 매김) 제한이 있는데요. (이걸 몰랐어요.. :scream:)

whileflag를 활용해서 Pagination 처리를 극복(?) 해줍니다.

get_all_pages.py
from atlassian import Confluence

confluence = Confluence(
    url='<confluence_url>',
    username='<id>',
    password='<password>')

page_ids = []
flag = True
limit = 500
step = 0

while flag:
    pages = confluence.get_all_pages_from_space(space=space, start=step * limit, limit=limit)
    step += 1  

    if len(pages) == 0:
        flag = False
    else:
        for page in pages :
            page_ids.append(page.get('id')) # page.get('title') 이라면 페이지 제목

# 전체 페이지 수
print(len(page_ids))

for page_id in page_ids :
    print(page_id) # 전체 페이지 ID 출력

참고링크

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?