Created
November 16, 2020 11:24
-
-
Save gusugusu1018/5a681da368ef8ea5c5713409fbb09082 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
import json | |
GROUP_ID='4940528' | |
ACCESS_TOKEN='*************' | |
END_POINT_URL='https://gitlab.com/api/v4/' | |
HEADERS={ | |
'Private-Token': ACCESS_TOKEN | |
} | |
projects_table = {} | |
api = '/groups/'+GROUP_ID+'/projects' | |
PER_PAGE=100 | |
done = False | |
page=1 | |
projNum=0 | |
reqCounter=0 | |
while not done: | |
ADDITIONAL_PARAM='?per_page='+str(PER_PAGE)+'&page='+str(page) | |
url = END_POINT_URL + api + ADDITIONAL_PARAM | |
response = requests.get(headers=HEADERS, url=url) | |
if len(response.json()) < PER_PAGE: | |
done = True | |
for p in response.json(): | |
projNum = projNum + 1 | |
print(projNum,'id:',p['id'], 'name:',p['name']) | |
projects_table[p['id']] = p['name'] | |
page = page + 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment