From 7b3457165e622c55456a6d084ca4c3db56fe63bd Mon Sep 17 00:00:00 2001 From: ShengQiBaoZao <99303427+ShengQiBaoZao@users.noreply.github.com> Date: Sat, 15 Jul 2023 10:05:40 +0800 Subject: [PATCH] =?UTF-8?q?=E9=92=88=E5=AF=B923-07-15=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E4=BA=86=E6=AD=A3=E5=88=99=EF=BC=8C=E5=B9=B6=E6=8C=89=E5=AD=97?= =?UTF-8?q?=E5=85=B8=E5=BA=8F=E6=8E=92=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/index.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/api/index.py b/api/index.py index 63deaa4..ea585ee 100644 --- a/api/index.py +++ b/api/index.py @@ -10,10 +10,15 @@ def getdata(name): gitpage = requests.get("https://github.com/" + name) data = gitpage.text datadatereg = re.compile(r'data-date="(.*?)" data-level') - datacountreg = re.compile(r'data-count="(.*?)" data-date') + datacountreg = re.compile(r'(.*?) contribution') datadate = datadatereg.findall(data) datacount = datacountreg.findall(data) - datacount = list(map(int, datacount)) + datacount = list(map(int, [0 if i == "No" else i for i in datacount])) + + # 将datadate和datacount按照字典序排序 + sorted_data = sorted(zip(datadate, datacount)) + datadate, datacount = zip(*sorted_data) + contributions = sum(datacount) datalist = [] for index, item in enumerate(datadate):