Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
F
foss2023-1_final
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Park MinSuk
foss2023-1_final
Commits
bffeef1b
Commit
bffeef1b
authored
1 year ago
by
Park MinSuk
Browse files
Options
Downloads
Patches
Plain Diff
sw.py 정리 + 주석
parent
f3ba0542
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
sw.py
+12
-13
12 additions, 13 deletions
sw.py
with
12 additions
and
13 deletions
sw.py
+
12
−
13
View file @
bffeef1b
...
...
@@ -4,24 +4,25 @@ from time import sleep
import
csv
Ajou_student
=
[]
pages
=
3
Ajou_student
=
[]
# 아주대학교 학생들 리스트
pages
=
3
# 받아올 페이지의 제한
group_id
=
328
# 아주대학교의 group_id 입니다.
for
page
in
range
(
pages
):
url
=
"
https://solved.ac/api/v3/ranking/in_organization?organizationId=
328
"
url
=
"
https://solved.ac/api/v3/ranking/in_organization?organizationId=
{group_id}
"
page_url
=
f
"
{
url
}
&page=
{
page
+
1
}
"
cnt
=
requests
.
get
(
page_url
)
Tmp_Ajou_student
=
json
.
loads
(
cnt
.
content
.
decode
(
"
utf-8
"
)).
get
(
"
items
"
)
Ajou_student
.
extend
([
user
.
get
(
"
handle
"
).
strip
()
for
user
in
Tmp_Ajou_student
])
def
solved_problem
(
user_handle
):
# 유저 아이디를 입력하면 유저가 푼 문제 목록을
확인해볼수있습니다.
def
solved_problem
(
user_handle
):
# 유저 아이디를 입력하면 유저가 푼 문제 목록을
return 하는 함수
url
=
f
"
https://solved.ac/api/v3/search/problem?query=s%40
{
user_handle
}
"
print
(
user_handle
)
cnt
=
json
.
loads
(
requests
.
get
(
url
).
content
.
decode
(
"
utf-8
"
))
pages
=
(
cnt
.
get
(
"
count
"
)
-
1
)
//
50
+
1
pid
=
[]
for
page
in
range
(
pages
):
sleep
(
1
)
sleep
(
1
)
# API 호출 횟수를 조절하기 위한 sleep 함수
page_url
=
f
"
{
url
}
&page=
{
page
+
1
}
"
cnt
=
json
.
loads
(
requests
.
get
(
page_url
).
content
.
decode
(
"
utf-8
"
))
problem_
=
cnt
.
get
(
"
items
"
)
...
...
@@ -30,16 +31,14 @@ def solved_problem(user_handle): # 유저 아이디를 입력하면 유저가
print
(
f
"
[
{
user_handle
}
]
{
page
}
/
{
pages
}
"
)
return
pid
limit
=
15
pid
=
{}
for
user
in
Ajou_student
[:
15
]:
for
user
in
Ajou_student
[:
limit
]:
user_problem
=
solved_problem
(
user
)
print
(
user
)
for
problem
in
user_problem
:
pid
[
problem
]
=
pid
.
get
(
problem
,
0
)
+
1
print
(
pid
)
pid
[
problem
]
=
pid
.
get
(
problem
,
0
)
+
1
# pid에 problem이 있다면 +1하고, 없다면 1을 채워줍니다.
with
open
(
"
top
15
_user_problem.csv
"
,
"
w
"
)
as
file
:
with
open
(
f
"
top
{
limit
}
_user_problem.csv
"
,
"
w
"
)
as
file
:
writer
=
csv
.
writer
(
file
)
for
k
,
v
in
pid
.
items
():
writer
.
writerow
([
k
,
v
])
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment