Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

合并2023-11的正则表达式更改,修复2024-02 因Vercel在不符合key-value规范的url后加等号导致的api失效 #22

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions api/index.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: UTF-8 -*-
import requests
import re
from http.server import BaseHTTPRequestHandler
Expand All @@ -9,8 +8,8 @@ def list_split(items, n):
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'<span class="sr-only">(.*?) contribution')
datadatereg = re.compile(r'data-date="(.*?)" id="contribution-day-component')
datacountreg = re.compile(r'position-absolute">(.*?) contribution')
datadate = datadatereg.findall(data)
datacount = datacountreg.findall(data)
datacount = list(map(int, [0 if i == "No" else i for i in datacount]))
Expand All @@ -33,7 +32,7 @@ def getdata(name):
class handler(BaseHTTPRequestHandler):
def do_GET(self):
path = self.path
user = path.split('?')[1]
user = path.split('?')[1][:-1]
data = getdata(user)
self.send_response(200)
self.send_header('Access-Control-Allow-Origin', '*')
Expand Down