-
Notifications
You must be signed in to change notification settings - Fork 0
/
Git_Clone_All.py
87 lines (65 loc) · 2.59 KB
/
Git_Clone_All.py
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
"""
Git-Clone-All is a clonning tool that clones all public github repositories of a User or organization with a single command.
Author: SpeedCuber (@yogendrasinghx)
Special Thanks to @tirthapriya12 ;)
"""
from bs4 import BeautifulSoup
import urllib2
import re
import os
import socket
# Console colors
G = '\033[32m' # green
Y = '\033[33m' #Yellow
B = '\033[34m' # blue
C = '\033[36m' # cyan
GR ='\033[37m' # gray
R = '\033[31m' # red
"""
Display ASCII art to make it cool ;)
"""
print B +" _____ _ _ _____ _ ___ _ _ "
print B +"| __ (_) | / __ \ | / _ \| | |"
print B +"| | \/_| |_ ______| / \/ | ___ _ __ ___ ______/ /_\ \ | |"
print B +"| | __| | __|______| | | |/ _ \| '_ \ / _ \______| _ | | |"
print B +"| |_\ \ | |_ | \__/\ | (_) | | | | __/ | | | | | |"
print B +" \____/_|\__| \____/_|\___/|_| |_|\___| \_| |_/_|_|\n"
print C +" Ver.1.0\n"
print C +" Author: SpeedCuber\n"
#Check internet connection
def internet_on():
try:
print (Y+"\r[.]Checking Internet Connection...\r")
host = socket.gethostbyname("www.google.com")
s = socket.create_connection((host, 80), 2)
return True
except:
pass
return False
if internet_on():
print G+"[OK] Connected\n"
username= raw_input(Y+'Enter Github Username : '+GR)
if not os.path.exists(username):
os.makedirs(username)
os.chdir(username)
#Count number of pages for repositories
html_page = urllib2.urlopen("https://github.com/"+username+"?page=1&tab=repositories")
soup = BeautifulSoup(html_page,"lxml")
for child in soup.find(class_=re.compile("Counter")):
count=int(child)
print G+"\n\n[+]"+str(count) + " Repositories Found!!\n"
nop=(count/30)+1; #Number of pages
#print nop
#Dump git URL and execute git clone command
for i in range(nop):
#print "https://github.com/"+username+"?page="+str(i+1)+"&tab=repositories"
html_page = urllib2.urlopen("https://github.com/"+username+"?page="+str(i+1)+"&tab=repositories")
soup = BeautifulSoup(html_page,"lxml")
for link in soup.findAll(itemprop="name codeRepository"):
catch="git clone https://github.com"+link.get('href')+".git"
#print "git clone https://github.com"+link.get('href')+".git"
print B+"\n=================================================================="+GR+"\n"
os.system(catch)
print('\x1b[6;30;42m' + '\nSuccess!' + '\x1b[0m')
else:
print R+"\nINTERNET IS NOT WORKING :( \n\n"