-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathGithub_Data.py
More file actions
executable file
·39 lines (28 loc) · 820 Bytes
/
Github_Data.py
File metadata and controls
executable file
·39 lines (28 loc) · 820 Bytes
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
import requests
from bs4 import BeautifulSoup
import urllib2
import pandas as pd
import numpy as np
# Stats Type List
t = ["Repositories", "Stars", "Followers", "Following"]
type = np.array(t)
l = []
def Get_Details():
#Get Username
x = raw_input("Enter the Github Username : ")
url = "https://github.com/" + x
user_file = urllib2.urlopen(url)
user_html = user_file.read()
user_file.close()
soup = BeautifulSoup(user_html, 'html.parser')
#Find all occurrences of the needed span class
data = soup.find_all('span', attrs={'class': 'counter'})
for i in data:
l.append(i.string)
Get_Details()
#Strip useless text from list elements
l = map(lambda s: s.strip(), l)
d = np.array(l)
print "User Details"
for i in range(0,4):
print str(type[i]) + " : " + str(d[i])