-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
133 lines (118 loc) · 4.32 KB
/
main.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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
import streamlit as sl
from time import time
from github_scrape import github_scrapped_data
from instagram_scrape import instagram_scrapped_data
from linkedin_scrape import linkedin_scrapped_data
from youtube_scrape import youtube_scrapped_data
sl.set_page_config(
page_title="Social Scraper",
page_icon="🎎"
)
sl.markdown(
"""
<h1 style='text-align:center'>Social Scrapper</h1>
""",
unsafe_allow_html=True,
)
sl.markdown("---")
social_media = sl.selectbox(
"Social Media Platform", options=["Linkedin", "Instagram", "GitHub", "YouTube"]
)
with sl.form("Form 1", clear_on_submit=True):
username = sl.text_input("Enter the username")
submit_button = sl.form_submit_button("Scrape")
sl.write("## Scrapped Data")
def get_data(username):
if social_media == "Linkedin":
return linkedin_scrapped_data(link_converter(username))
elif social_media == "GitHub":
return github_scrapped_data(link_converter(username))
elif social_media == "Instagram":
return instagram_scrapped_data(link_converter(username))
else:
return youtube_scrapped_data(link_converter(username))
def link_converter(username):
if social_media == "Linkedin":
return "https://www.linkedin.com/in/" + username + "/"
elif social_media == "GitHub":
return "https://github.com/" + username
elif social_media == "Instagram":
return "https://www.instagram.com/" + username + "/"
else:
return "https://www.youtube.com/" + username + "/"
def github_data_onclick():
scraped_data = get_data(username)
if scraped_data[0] == "Data not available" or scraped_data == "":
sl.error("### Account data not available")
else:
sl.write("##")
if scraped_data[0] == "":
sl.warning("Name not available")
else:
sl.write(f"### Name: {scraped_data[0]}")
sl.write("##")
sl.image(scraped_data[1], width=300, caption=f"{username}'s Image")
sl.write("##")
if scraped_data[2] == "":
sl.warning("Bio not available")
else:
sl.write("### Bio: ")
sl.write(f"{scraped_data[2]}")
sl.write("##")
try:
sl.write(f"### Followers: {scraped_data[3]}")
except:
sl.warning("### Followers not available")
try:
sl.write(f"### Following: {scraped_data[4]}")
except:
sl.warning("### Followings not available")
sl.write("##")
sl.write(f"### {username}'s contribution badges: ")
try:
badges_row = sl.columns(len(scraped_data[5]))
for index, link in enumerate(scraped_data[5]):
badges_row[index].image(link, width=100)
except:
sl.warning("Badges not available")
sl.write("##")
sl.write(f"### Total public commits: {scraped_data[6]}")
sl.write("##")
sl.write("### Commit overview: ")
sl.write(f"{scraped_data[7][21:]}")
sl.write("##")
for repo in scraped_data[8]:
heading = str(repo["serial_number"]) + "- " + repo["name"]
with sl.expander(heading):
sl.markdown("""Link - [Link to project](repo["url"])""")
if repo["description"] == "Data not available":
sl.warning("Description of the project is not available")
else:
sl.write("Description: " + repo["description"])
if repo["language"] == "Data not available":
sl.warning("Programming Language of the project is not available")
else:
sl.write("Description: " + repo["language"])
sl.write("Last updated on: " + repo["last_updated"])
def scrap_time():
end = time()
time_taken = format((end - start), ".2f")
time_taken = "Scraped in " + str(time_taken) + " seconds"
sl.success(time_taken)
if submit_button:
if social_media == "GitHub":
start = time()
github_data_onclick()
scrap_time()
elif social_media == "Instagram":
start = time()
sl.write(get_data(username))
scrap_time()
elif social_media == "Linkedin":
start = time()
sl.write(get_data(username))
scrap_time()
else:
start = time()
sl.write(get_data(username))
scrap_time()