From 54426a3a7c7739afc229af048e79b3c876b3a5b7 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Fri, 14 Sep 2018 14:45:55 +0800 Subject: [PATCH] 1 --- gitlab/githelper.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/gitlab/githelper.py b/gitlab/githelper.py index c8d95dd..44f0dbb 100644 --- a/gitlab/githelper.py +++ b/gitlab/githelper.py @@ -1,9 +1,17 @@ +import json import urllib.request def httpGet(url, params={}): real_url = url + urllib.parse.urlencode(params) req = urllib.request.Request(real_url) req.add_header('Private-Token', 'cRjSP2EUx1SaQYcis9W7') - print(urllib.request.urlopen(req).read()) + data = urllib.request.urlopen(req).readall() + return json.loads(data.decode('utf-8')) -httpGet('http://git.kingsome.cn/api/v4/projects') +projects = httpGet('http://git.kingsome.cn/api/v4/projects?', + { + 'page': 1, + 'per_page': 1000 + }) +for proj in projects: + print(proj['path_with_namespace'])