Skip to content

Commit a3273f2

Browse files
authored
add header
1 parent 02bd214 commit a3273f2

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

api/index.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@
77
def list_split(items, n):
88
return [items[i:i + n] for i in range(0, len(items), n)]
99
def getdata(name):
10-
gitpage = requests.get("https://github.com/" + name)
10+
import urllib.request
11+
headers = {
12+
'User-Agent': 'Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.114 Safari/537.36'}
13+
gitpage = requests.get("https://github.com/" + name, headers=headers)
1114
data = gitpage.text
1215
datadatereg = re.compile(r'data-date="(.*?)" data-level')
1316
datacountreg = re.compile(r'data-count="(.*?)" data-date')

0 commit comments

Comments
 (0)