|
| 1 | +from github import Github |
| 2 | +from datetime import datetime |
| 3 | +import time |
| 4 | +import os |
| 5 | + |
| 6 | +ACCESS_TOKEN = open("token.txt", "r").read() |
| 7 | +github = Github(ACCESS_TOKEN) |
| 8 | + |
| 9 | +SECONDS_IN_A_DAY = 86400 |
| 10 | + |
| 11 | +end_time = time.time() |
| 12 | +start_time = end_time - SECONDS_IN_A_DAY |
| 13 | + |
| 14 | +for i in range(3): |
| 15 | + start_time_str = datetime.utcfromtimestamp(start_time).strftime("%Y-%m-%d") |
| 16 | + end_time_str = datetime.utcfromtimestamp(end_time).strftime("%Y-%m-%d") |
| 17 | + |
| 18 | + query = f"language:python created:{start_time_str}..{end_time_str}" |
| 19 | + print(query) |
| 20 | + |
| 21 | + start_time -= SECONDS_IN_A_DAY |
| 22 | + end_time -= SECONDS_IN_A_DAY |
| 23 | + |
| 24 | + result = github.search_repositories(query) |
| 25 | + print(result.totalCount) |
| 26 | + |
| 27 | + for repository in result: |
| 28 | + print(repository.clone_url) |
| 29 | + os.system(f"git clone {repository.clone_url} repos/{repository.owner.login}/{repository.name}") |
| 30 | + |
0 commit comments