Skip to content

Instantly share code, notes, and snippets.

@return0927
Created May 25, 2018 16:49
Show Gist options
  • Save return0927/88a5a41d10c2f4b37c4128eb2f7aa309 to your computer and use it in GitHub Desktop.
Save return0927/88a5a41d10c2f4b37c4128eb2f7aa309 to your computer and use it in GitHub Desktop.
비엘소프트사, 대전중앙고의 방과후신청사이트의 현황을 로그파일로 저장해주는 모니터 스크립트입니다. (2018 3차방과후신청 기준)
from requests import get
from time import time, strftime
lectures = [454, 462, 461, 460, 457, 459, 458, 455, 456, 470, 471, 468, 466, 467, 464, 465, 463, 469]
titles = {"454": "고전시가강독반2 [오창학, 2-1]", "462": "농구 3on3 경기반 [이원규, 운동장 및 체육관]", "461": "물리탐구반 [김태수, 2-8]",
"460": "손에잡히는 생명과학 [임언식, 2-9]", "457": "솔루션 독해 [오향희, 2-5]", "459": "수리연구반 [백흥관, 2-7]",
"458": "수학문제해결력향상반 [임광선, 2-6]", "455": "창의영어독해반 [이진웅, 2-3]", "456": "홀로서는 독서와문법반 [이의준, 2-4]",
"470": "물리탐구반 [김태수, 2-8]", "471": "배구경기기능향상반 [이원규, 운동장 및 체육관]", "468": "사고력 신장반 [강윤화, 2-7]",
"466": "솔루션 독해 [오향희, 2-5]", "467": "쉬운미적분, 빠른미적분 [임광선, 2-6]", "464": "인간의 삶과 윤리 [홍지연, 2-2]",
"465": "토론실전반 [이의준, 2-4]", "463": "현대시 특강반 [이수정, 2-1]", "469": "화학개념응용반 [홍은희, 2-9]"}
def parse(uri="https://djja.yschool.co.kr:446/m/lec_json.php?caseBy=resetinwon&idx=dkey_{}", debug=False):
data = []
for val in titles.keys():
resp = get(uri.format(val))
k = titles[val] + " " + resp.text.replace("<span style='color:blue;'>","").replace("</span>","")
data.append(
k
)
if debug: print(k)
return data
def loop():
start = 0
while True:
if time() - start > 1:
start = time()
p = parse()
open(strftime("%Y%m%d.log"),"a", encoding="UTF-8")\
.write(
"""{}\t{}\n""".format(
strftime("%Y.%m.%d %H:%M:%S"),
repr(p)
)
)
print("Done! {}~{}".format(start, time()))
loop()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment