Created
February 6, 2018 05:04
-
-
Save anonymous/48bda4a59976281e411273b42aaa283d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding:utf-8 -*- | |
# @Filename : clone.py | |
# @Date : 18-2-6 12:36 | |
# @Author : DebuggerX | |
import re | |
import urllib | |
import subprocess | |
import os | |
repositories = [] | |
def get_page(url, index): | |
html = urllib.urlopen('%s?page=%d' % (url, index)).read() | |
if html and "Page not found" not in html and 'This organization has no more repositories' not in html: | |
assert isinstance(html, str) | |
shtmls = re.findall("href=\".+\" itemprop=\"name codeRepository\"", html) | |
for shtml in shtmls: | |
assert isinstance(shtml, str) | |
repositories.append(shtml[6:shtml.find('" itemprop')]) | |
print("正在分析第%d页" % index) | |
index += 1 | |
get_page(baseUrl, index) | |
else: | |
pass | |
if __name__ == '__main__': | |
account = raw_input('请输入github用户名,将分析该账户下所有仓库\n') | |
baseUrl = 'https://github.com/%s' % account | |
print("开始分析仓库。。。") | |
get_page(baseUrl, 1) | |
print("总共得到%d条仓库信息" % len(repositories)) | |
print("开始抓取各个仓库") | |
cmd = '' | |
for repository in repositories: | |
print('https://github.com%s' % repository) | |
print('按任意键开始克隆以上所有仓库') | |
subprocess.call("bash -c 'read' '-n' '1'", shell=True) | |
for repository in repositories: | |
os.system('git clone https://github.com%s.git' % repository) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment