-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgithub repositories.py
41 lines (35 loc) · 1.11 KB
/
github repositories.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
import bs4 as bs
import urllib.request
username = input('enter github username - ')
print("wait!!! It may take sometime")
print()
url = "https://github.com/"+username
sauce = urllib.request.urlopen(url).read()
soup = bs.BeautifulSoup(sauce,'lxml') # lxml is a parser
#print(soup)
repoNo = int(soup.find('span',class_='Counter').text)
n1 = repoNo
print("No. of repositories = ",n1)
print()
url2 = url + "?tab=repositories"
sauce = urllib.request.urlopen(url2).read()
soup = bs.BeautifulSoup(sauce,'lxml')
#print(soup)
arr = [0]
tags = soup.find_all('a', itemprop="name codeRepository")
for tag in tags:
if tag.text!="":
arr.append((tag.text).lstrip())
k=2
while(len(arr)<=n1):
url3 = url + "?page="+str(k)+"&tab=repositories"
k+=1
sauce = urllib.request.urlopen(url3).read()
soup = bs.BeautifulSoup(sauce,'lxml')
tags = soup.find_all('a', itemprop="name codeRepository")
for tag in tags:
if tag.text!="":
arr.append((tag.text).lstrip())
for i in range(1,len(arr)):
h1 = str(i) + ". "+str(arr[i])
print(h1)