谁说github不封号?谁说github只封仓库
特别是jsdelivr图床,挂违规Actions
还是做个备份吧,不然没地方哭
事由:给我宝贝的github新账号开一个action,跑一下签到的任务,两分钟直接封禁!(就nm离谱)
动力:我怕我也被封禁,仓库未备份岂不是一切重来……
思路:GitHub用户仓库批量下载 (但是这个方法夭折了)
准备工作:
1.本地浏览器须登录本人github,存在cookie (强烈建议,未登录未尝试)
2.需要确保电脑上安装了 git (可以去 官网 下载)
3.python3.8环境 (版本>3就行)
4.拿到登录github的 “user-agent” 和”cookie” (百度)
5.手
步骤:
1.将登录github的 “user-agent” 和”cookie”填入末尾代码
2.运行py程序
3.输入github用户名(https:/github.com/Adsryen)红色就是用户名
4.将运行目录生成的bat文件移到将要备份到本地的文件夹,双击运行!OVER!!!
完整代码:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
| import requests import re HEADERS = {"user-agent": "", "cookie":""} first_url = 'https://github.com'
def get_repositories(url): response = requests.get(url=url, headers=HEADERS) html = response.text second_urls = re.findall('<a href="(.*?)" itemprop="name codeRepository" >',html) for second_url in second_urls: global first_url output = first_url + str(second_url) + '.git' print(output) with open('clone.bat','a+') as f: f.writelines('git clone --depth=1 ' + output + '\n') def next_url(username,url): response = requests.get(url=url, headers=HEADERS) html = response.text next_url = 'https://github.com/'+ username + '?after=' + str(re.findall('href="https://github.com/Adsryen\\?after=(.*?)">Next</a>', html)).strip()[2:-2] if next_url.strip() == '': print('项目已结束') else: return next_url if __name__ == '__main__': username = input('请输入github的用户名:') url = 'https://github.com/' + username + '?tab=repositories' get_repositories(url) for num in range(10): url = next_url(username,url) get_repositories(url)
|