Skip to content

Commit

Permalink
针对23-07-15更新了正则,并按字典序排序
Browse files Browse the repository at this point in the history
  • Loading branch information
ShanMuYunQiu authored Jul 15, 2023
1 parent 02bd214 commit 7b34571
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions api/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'<span class="sr-only">(.*?) 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):
Expand Down

0 comments on commit 7b34571

Please sign in to comment.