1## you should install github API first:
2# pip install PyGithub
3
4# with this code you grab python code from specific day until today.
5from github import Github
6from datetime import datetime
7import time
8import os
9
10
11
12
13g = Github('***') #here you pu your github token
14# see rescurce to learn more about github token
15
16end_time = time.time()
17end_time_str = datetime.utcfromtimestamp(end_time).strftime('%Y-%m-%d')
18start_time = time.time() - 86400
19start_time_str = datetime.utcfromtimestamp(start_time).strftime('%Y-%m-%d')
20id=0
21for i in range(3): #The number 3 means that all python
22 #code will be grabed from 3 day ago
23 try:
24 query = f"language:python created:{start_time_str}..{end_time_str}"
25 end_time = start_time
26 start_time -= 86400
27 start_time_str = datetime.utcfromtimestamp(start_time).strftime('%Y-%m-%d')
28 end_time_str = datetime.utcfromtimestamp(end_time).strftime('%Y-%m-%d')
29
30 result = g.search_repositories(query)
31 id=0
32 for repo in result:
33 id+=1
34 os.system(f'git clone {repo.clone_url} repo/{repo.owner.login}/{repo.name}_{id}')
35
36
37
38
39