-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscraperBetter.py
More file actions
190 lines (153 loc) · 5.38 KB
/
Copy pathscraperBetter.py
File metadata and controls
190 lines (153 loc) · 5.38 KB
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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
# scraper.py
# basic functions to scrabe devpost data
from datetime import datetime
from bs4 import BeautifulSoup
import requests
baseURL = "https://deltahacks-x.devpost.com/"
# baseURL = "https://sase-lsu-geaux-hack-2023.devpost.com/"
# checking first page
desiredStartPage = "project-gallery"
page = requests.get(baseURL + desiredStartPage)
curPage = page
projects = []
soup = BeautifulSoup(page.content, "html.parser")
projects += soup.find_all(
"a", class_=["block-wrapper", "link.fade", "link-to-software"]
)
curPage = soup.find("a", rel=["next"])
# checking subsequent pages
while curPage != None:
page = requests.get(baseURL + curPage["href"])
soup = BeautifulSoup(page.content, "html.parser")
projects += soup.find_all(
"a", class_=["block-wrapper", "link.fade", "link-to-software"]
)
curPage = soup.find("a", rel=["next"])
# getting all project links
projectLinks = []
for link in projects:
projectLinks.append(link["href"])
print(projectLinks)
print(len(projectLinks))
allTeams = []
# go through each project found
for link in projectLinks:
page = requests.get(link)
soup = BeautifulSoup(page.content, "html.parser")
# get project title
title = soup.find(id="app-title")
print(title.text)
# get project description
description = soup.find("p", class_="large")
print(description.text)
# get all project description
fullInformation = soup.find(id="app-details-left")
# ul tags is class=cp-tag
if fullInformation is not None:
innerDivs = fullInformation.find_all("div")
innerLength = len(innerDivs)
# inner html components
for div in innerDivs[innerLength - 2]:
print(div.text)
# built with section
for div in innerDivs[innerLength - 1]:
print(div.get_text(" "))
# print(div.text)
# get github url (if it exists)
softwareURLS = fullInformation.find(
"ul", attrs={"data-role": True}, class_="no-bullet"
)
# find URLS containing github
if softwareURLS is not None:
for url in softwareURLS.find_all("a"):
if "https://github.com" in url["href"]:
github = url["href"]
print(github)
# get all team members
teamMembers = soup.find_all("li", class_="software-team-member")
members = []
for member in teamMembers:
memberLink = member.find("a", class_="user-profile-link")
if memberLink is not None:
members.append(memberLink["href"])
print(members)
# add to all teams list
allTeams.append(members)
print(allTeams)
# go through all of their projects and do checks
# access github commits
githubURL = "https://github.com/richardl2003/LaaS"
def getGithubCommits(githubURL):
# note: this assumes their commits are on main!
githubURL += "/commits/main/"
page = requests.get(githubURL)
soup = BeautifulSoup(page.content, "html.parser")
# want h3 with data-testid="commit-group-title"
commits = soup.find_all("h3", attrs={"data-testid": "commit-group-title"})
for commit in commits:
commitText = commit.text
# save commit dates
# get date from text
date = commitText.split(" on ")[1]
print(date)
# as of rn only selecting date
datetime_object = datetime.strptime(date, "%b %d, %Y")
print(datetime_object)
# potential flags
# commit date before hackathon start date
# flag if 1 commit only
# flag if only one user commiting (if team 2>)
getGithubCommits(githubURL)
# # teams
# hackerURL = "https://devpost.com/kennyzhao-code"
def getProjectsFromHacker(hackerURL):
# checking first page
# desiredStartPage = "project-gallery"
page = requests.get(hackerURL)
# curPage = page
# projects = []
soup = BeautifulSoup(page.content, "html.parser")
projects = soup.find_all(
"a", class_=["block-wrapper-link", "fade", "link-to-software"]
)
# curPage = soup.find("a", rel=["next"])
# prints the projects in a list
projectLinks = []
for link in projects:
projectLinks.append(link["href"])
print(projectLinks)
print(len(projectLinks))
# allTeams = []
projectRepos = []
for link in projectLinks:
page = requests.get(link)
soup = BeautifulSoup(page.content, "html.parser")
# # get project title
# title = soup.find(id="app-title")
# print(title.text)
# # get project description
# description = soup.find("p", class_="large")
# print(description.text)
# get all project description
fullInformation = soup.find(id="app-details-left")
# ul tags is class=cp-tag
# if fullInformation is not None:
# innerDivs = fullInformation.find_all("div")
# for div in innerDivs[1:]:
# print(div.text)
# get github url (if it exists)
softwareURLS = fullInformation.find(
"ul", attrs={"data-role": True}, class_="no-bullet"
)
# find URLS containing github
if softwareURLS is not None:
for url in softwareURLS.find_all("a"):
if "https://github.com" in url["href"]:
github = url["href"]
projectRepos.append(github)
print(projectRepos)
for team in allTeams:
print(team)
for member in team:
print(member)
getProjectsFromHacker(member)