diff options
| author | Christian Krinitsin <mail@krinitsin.com> | 2025-05-15 11:19:14 +0200 |
|---|---|---|
| committer | Christian Krinitsin <mail@krinitsin.com> | 2025-05-15 11:19:14 +0200 |
| commit | 64c7d5de4cc2cb906542dc01ad176c7ed5089c7e (patch) | |
| tree | de7a679c8349815479c8ff4d4c05a780a44949a3 /downloader.py | |
| download | qemu-analysis-64c7d5de4cc2cb906542dc01ad176c7ed5089c7e.tar.gz qemu-analysis-64c7d5de4cc2cb906542dc01ad176c7ed5089c7e.zip | |
add main script: iterates through issues, extracts necessary data and prints new json
Diffstat (limited to 'downloader.py')
| -rwxr-xr-x | downloader.py | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/downloader.py b/downloader.py new file mode 100755 index 000000000..9fe905a3c --- /dev/null +++ b/downloader.py @@ -0,0 +1,39 @@ +from requests import get +from json import dumps + +project_id = 11167699 +per_page = 100 +url = f"https://gitlab.com/api/v4/projects/{project_id}/issues?per_page={per_page}" + +def pages_iterator(first): + current = first + while current.links.get('next'): + current.raise_for_status() + yield current + current = get(url = current.links.get('next').get('url')) + current.raise_for_status() + yield current + +def main(): + for response in pages_iterator(get(url = url)): + print(f"Current page: {response.headers['x-page']}") + + data = response.json() + for i in data: + + issue = { + "id": i['iid'], + "title": i['title'], + "state": i['state'], + "description": i['description'], + "created_at": i['created_at'], + "closed_at": i['closed_at'], + "labels": i['labels'], + "url": i['web_url'] + } + + json_string = dumps(obj = issue, indent = 2) + print(json_string) + +if __name__ == "__main__": + main() |