Skip to content

Commit 392b957

Browse files
committed
change
1 parent ef21d9b commit 392b957

1 file changed

Lines changed: 1 addition & 11 deletions

File tree

api/index.py

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
import requests
33
from http.server import BaseHTTPRequestHandler
44
import json
5-
import os
65
from bs4 import BeautifulSoup
76
headers = {
87
"accept": "text/html",
@@ -21,13 +20,7 @@ def list_split(items, n):
2120
return [items[i:i + n] for i in range(0, len(items), n)]
2221
def getdata(name):
2322
gitpage = requests.get("https://github.com/" + name + "?action=show&controller=profiles&tab=contributions&user_id=" + name, headers=headers)
24-
data = gitpage.text
25-
# 写入文件
26-
with open('data.html', 'w', encoding='utf-8') as file:
27-
file.write(data)
28-
# with open(htmltext, 'r', encoding='utf-8') as file:
29-
# dataStr = file.read()
30-
data = BeautifulSoup(data, 'html.parser')
23+
data = BeautifulSoup(gitpage.text, 'html.parser')
3124
dataEle = data.find_all('td', class_='ContributionCalendar-day', attrs={'data-date': True})
3225
datadate = [item.attrs['data-date'] for item in dataEle]
3326
datacount = [int(item.attrs['data-level']) for item in dataEle]
@@ -76,7 +69,4 @@ def do_GET(self):
7669
self.end_headers()
7770
self.wfile.write(json.dumps(data).encode('utf-8'))
7871
return
79-
# BaseHTTPRequestHandler(('0.0.0.0', PORT), handler).serve_forever()
80-
# def main(port):
81-
# BaseHTTPRequestHandler(('0.0.0.0', port), handler).serve_forever()
8272

0 commit comments

Comments
 (0)