This repository was archived by the owner on Jan 19, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathparseRecentProbs.py
More file actions
30 lines (28 loc) · 1.48 KB
/
parseRecentProbs.py
File metadata and controls
30 lines (28 loc) · 1.48 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
import json # json 파일을 다루기 위한 모듈
import requests
from Database import Database
if __name__ == "__main__":
recent = Database()
recent.readDB("recent.json")
with open("recent.md", "w", encoding="utf-8") as f:
f.write("| 문제 번호 | 문제 이름 | 난이도 | 풀이 코드 |\n")
f.write("| --- | --- | --- | --- |\n")
for problem in recent.DB["problems"]:
id = problem["id"]
title = problem["title"]
level = problem["level"]
URL = f"https://ingyu1008.github.io/boj/ps/BOJ{id}"
with requests.get(URL) as res:
if(res.status_code == 200):
solution = f"[풀이](https://ingyu1008.github.io/boj/ps/BOJ{id})"
else:
solution = "NONE"
URL = f"https://github.com/ingyu1008/Algorithm-Problem-Solving/tree/master/Baekjoon%20Online%20Judge/{title}"
if solution == "NONE":
with requests.get(URL) as res:
if(res.status_code == 200):
solution = f"[코드](<https://github.com/ingyu1008/Algorithm-Problem-Solving/tree/master/Baekjoon%20Online%20Judge/{title}/solution.cpp>)"
else:
solution = ""
f.write(f"| {id} | [{title}](https://www.acmicpc.net/problem/{id}) | <img height=\"25px\" width=\"25px=\" src=\"https://static.solved.ac/tier_small/{level}.svg\"/> | {solution} |\n")
f.close()