From c01873bd3d3973a6d88e538432b46df6d28284ea Mon Sep 17 00:00:00 2001 From: Soobin Park <79681981+estrellalila@users.noreply.github.com> Date: Tue, 20 Aug 2024 11:36:26 +0900 Subject: [PATCH] =?UTF-8?q?=EC=A0=84=EA=B3=B5=ED=81=AC=EB=A1=A4=EB=A7=81?= =?UTF-8?q?=20=EC=99=84=EB=A3=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../\354\240\204\352\263\265re10.py" | 813 ++++++++++++++++++ .../\354\240\204\352\263\265re11.py" | 438 ++++++++++ .../\354\240\204\352\263\265re8.py" | 602 +++++++++++++ .../\354\240\204\352\263\265re9.py" | 263 ++++++ 4 files changed, 2116 insertions(+) create mode 100644 "\355\201\254\353\241\244\353\247\201 \354\275\224\353\223\234/\354\240\204\352\263\265re10.py" create mode 100644 "\355\201\254\353\241\244\353\247\201 \354\275\224\353\223\234/\354\240\204\352\263\265re11.py" create mode 100644 "\355\201\254\353\241\244\353\247\201 \354\275\224\353\223\234/\354\240\204\352\263\265re8.py" create mode 100644 "\355\201\254\353\241\244\353\247\201 \354\275\224\353\223\234/\354\240\204\352\263\265re9.py" diff --git "a/\355\201\254\353\241\244\353\247\201 \354\275\224\353\223\234/\354\240\204\352\263\265re10.py" "b/\355\201\254\353\241\244\353\247\201 \354\275\224\353\223\234/\354\240\204\352\263\265re10.py" new file mode 100644 index 0000000..e0c3a04 --- /dev/null +++ "b/\355\201\254\353\241\244\353\247\201 \354\275\224\353\223\234/\354\240\204\352\263\265re10.py" @@ -0,0 +1,813 @@ +import urllib.request as req +from bs4 import BeautifulSoup +import pandas as pd + +#학수번호 - 분반 +cour_num = [] +#과목명 +cour_name = [] +#교수명 +cour_prof = [] +#학점 +cour_credit = [] +#이수구분 +cour_division = [] +#강의시간 및 장소 +cour_time__location = [] + +major_001 = {'COED' : '4064'} +major_201 = { 'LBNC':'6093'} +major_202 = {'GLEA':'6095', 'MHUM':'6342'} + +major_301 = {'AICE' : '6545'} +major_303 = {'ISEC':'5944'} +major_315 = { 'BNCS':'6666'} + +for key, value in major_001.items(): + url = "https://infodepot.korea.ac.kr/lecture1/lecsubjectPlanViewNew.jsp?year=2024&term=2R&grad_cd=0136&col_cd=9999&dept_cd="+ value +"&cour_cd=" + key + '001' + "&cour_cls=" + '00' + "&" + html = req.urlopen(url) + doc = BeautifulSoup(html,"html.parser") + h3_tag = doc.find('h3') + + if (not h3_tag) or not h3_tag.string or len(h3_tag.string) == 19: + print('no site') + continue + + try: + rows = doc.find(class_="tbl_view").tbody.find_all('tr') + #학점 + credit = rows[0].find_all('td')[1].text.strip() + #이수구분 + division = rows[2].find_all('td')[0].text.strip() + #학수번호-분반 + number_class = rows[1].find_all('td')[0].text.strip() + #강의시간표 및 장소 + time_location = rows[3].find_all('td')[1].text.strip() + #과목명 + title = rows[4].find_all('td')[0].text.strip() + #교수명 + prof = doc.find(class_="bottom_view").find_all('tr')[0].find_all('td')[0].text.strip() + + except Exception as e: + print(f"Error parsing {url}: {e}") + time = None + prof = None + course_credit = None + course_division = None + course_code_sec = None + course_schedule_location = None + + cour_prof.append(prof) + # cour_number = f'GEST{str(num).zfill(3)}-{str(cour_cls).zfill(2)}' + cour_name.append(title) + cour_credit.append(credit) + cour_division.append(division) + cour_num.append(number_class) + cour_time__location.append(time_location) + + print(f"{number_class} 완료") + +for key, value in major_201.items(): + url = "https://infodepot.korea.ac.kr/lecture1/lecsubjectPlanViewNew.jsp?year=2024&term=2R&grad_cd=0136&col_cd=9999&dept_cd="+ value +"&cour_cd=" + key + '201' + "&cour_cls=" + '00' + "&" + html = req.urlopen(url) + doc = BeautifulSoup(html,"html.parser") + h3_tag = doc.find('h3') + + if (not h3_tag) or not h3_tag.string or len(h3_tag.string) == 19: + print('no site') + continue + + try: + rows = doc.find(class_="tbl_view").tbody.find_all('tr') + #학점 + credit = rows[0].find_all('td')[1].text.strip() + #이수구분 + division = rows[2].find_all('td')[0].text.strip() + #학수번호-분반 + number_class = rows[1].find_all('td')[0].text.strip() + #강의시간표 및 장소 + time_location = rows[3].find_all('td')[1].text.strip() + #과목명 + title = rows[4].find_all('td')[0].text.strip() + #교수명 + prof = doc.find(class_="bottom_view").find_all('tr')[0].find_all('td')[0].text.strip() + + except Exception as e: + print(f"Error parsing {url}: {e}") + time = None + prof = None + course_credit = None + course_division = None + course_code_sec = None + course_schedule_location = None + + cour_prof.append(prof) + # cour_number = f'GEST{str(num).zfill(3)}-{str(cour_cls).zfill(2)}' + cour_name.append(title) + cour_credit.append(credit) + cour_division.append(division) + cour_num.append(number_class) + cour_time__location.append(time_location) + + print(f"{number_class} 완료") + +for key, value in major_202.items(): + url = "https://infodepot.korea.ac.kr/lecture1/lecsubjectPlanViewNew.jsp?year=2024&term=2R&grad_cd=0136&col_cd=9999&dept_cd="+ value +"&cour_cd=" + key + '202' + "&cour_cls=" + '00' + "&" + html = req.urlopen(url) + doc = BeautifulSoup(html,"html.parser") + h3_tag = doc.find('h3') + + if (not h3_tag) or not h3_tag.string or len(h3_tag.string) == 19: + print('no site') + continue + + try: + rows = doc.find(class_="tbl_view").tbody.find_all('tr') + #학점 + credit = rows[0].find_all('td')[1].text.strip() + #이수구분 + division = rows[2].find_all('td')[0].text.strip() + #학수번호-분반 + number_class = rows[1].find_all('td')[0].text.strip() + #강의시간표 및 장소 + time_location = rows[3].find_all('td')[1].text.strip() + #과목명 + title = rows[4].find_all('td')[0].text.strip() + #교수명 + prof = doc.find(class_="bottom_view").find_all('tr')[0].find_all('td')[0].text.strip() + + except Exception as e: + print(f"Error parsing {url}: {e}") + time = None + prof = None + course_credit = None + course_division = None + course_code_sec = None + course_schedule_location = None + + cour_prof.append(prof) + # cour_number = f'GEST{str(num).zfill(3)}-{str(cour_cls).zfill(2)}' + cour_name.append(title) + cour_credit.append(credit) + cour_division.append(division) + cour_num.append(number_class) + cour_time__location.append(time_location) + + print(f"{number_class} 완료") + +for key, value in major_301.items(): + url = "https://infodepot.korea.ac.kr/lecture1/lecsubjectPlanViewNew.jsp?year=2024&term=2R&grad_cd=0136&col_cd=9999&dept_cd="+ value +"&cour_cd=" + key + '301' + "&cour_cls=" + '00' + "&" + html = req.urlopen(url) + doc = BeautifulSoup(html,"html.parser") + h3_tag = doc.find('h3') + + if (not h3_tag) or not h3_tag.string or len(h3_tag.string) == 19: + print('no site') + continue + + try: + rows = doc.find(class_="tbl_view").tbody.find_all('tr') + #학점 + credit = rows[0].find_all('td')[1].text.strip() + #이수구분 + division = rows[2].find_all('td')[0].text.strip() + #학수번호-분반 + number_class = rows[1].find_all('td')[0].text.strip() + #강의시간표 및 장소 + time_location = rows[3].find_all('td')[1].text.strip() + #과목명 + title = rows[4].find_all('td')[0].text.strip() + #교수명 + prof = doc.find(class_="bottom_view").find_all('tr')[0].find_all('td')[0].text.strip() + + except Exception as e: + print(f"Error parsing {url}: {e}") + time = None + prof = None + course_credit = None + course_division = None + course_code_sec = None + course_schedule_location = None + + cour_prof.append(prof) + # cour_number = f'GEST{str(num).zfill(3)}-{str(cour_cls).zfill(2)}' + cour_name.append(title) + cour_credit.append(credit) + cour_division.append(division) + cour_num.append(number_class) + cour_time__location.append(time_location) + + print(f"{number_class} 완료") + +for key, value in major_303.items(): + url = "https://infodepot.korea.ac.kr/lecture1/lecsubjectPlanViewNew.jsp?year=2024&term=2R&grad_cd=0136&col_cd=9999&dept_cd="+ value +"&cour_cd=" + key + '303' + "&cour_cls=" + '00' + "&" + html = req.urlopen(url) + doc = BeautifulSoup(html,"html.parser") + h3_tag = doc.find('h3') + + if (not h3_tag) or not h3_tag.string or len(h3_tag.string) == 19: + print('no site') + continue + + try: + rows = doc.find(class_="tbl_view").tbody.find_all('tr') + #학점 + credit = rows[0].find_all('td')[1].text.strip() + #이수구분 + division = rows[2].find_all('td')[0].text.strip() + #학수번호-분반 + number_class = rows[1].find_all('td')[0].text.strip() + #강의시간표 및 장소 + time_location = rows[3].find_all('td')[1].text.strip() + #과목명 + title = rows[4].find_all('td')[0].text.strip() + #교수명 + prof = doc.find(class_="bottom_view").find_all('tr')[0].find_all('td')[0].text.strip() + + except Exception as e: + print(f"Error parsing {url}: {e}") + time = None + prof = None + course_credit = None + course_division = None + course_code_sec = None + course_schedule_location = None + + cour_prof.append(prof) + # cour_number = f'GEST{str(num).zfill(3)}-{str(cour_cls).zfill(2)}' + cour_name.append(title) + cour_credit.append(credit) + cour_division.append(division) + cour_num.append(number_class) + cour_time__location.append(time_location) + + print(f"{number_class} 완료") + +for key, value in major_315.items(): + url = "https://infodepot.korea.ac.kr/lecture1/lecsubjectPlanViewNew.jsp?year=2024&term=2R&grad_cd=0136&col_cd=9999&dept_cd="+ value +"&cour_cd=" + key + '315' + "&cour_cls=" + '00' + "&" + html = req.urlopen(url) + doc = BeautifulSoup(html,"html.parser") + h3_tag = doc.find('h3') + + if (not h3_tag) or not h3_tag.string or len(h3_tag.string) == 19: + print('no site') + continue + + try: + rows = doc.find(class_="tbl_view").tbody.find_all('tr') + #학점 + credit = rows[0].find_all('td')[1].text.strip() + #이수구분 + division = rows[2].find_all('td')[0].text.strip() + #학수번호-분반 + number_class = rows[1].find_all('td')[0].text.strip() + #강의시간표 및 장소 + time_location = rows[3].find_all('td')[1].text.strip() + #과목명 + title = rows[4].find_all('td')[0].text.strip() + #교수명 + prof = doc.find(class_="bottom_view").find_all('tr')[0].find_all('td')[0].text.strip() + + except Exception as e: + print(f"Error parsing {url}: {e}") + time = None + prof = None + course_credit = None + course_division = None + course_code_sec = None + course_schedule_location = None + + cour_prof.append(prof) + # cour_number = f'GEST{str(num).zfill(3)}-{str(cour_cls).zfill(2)}' + cour_name.append(title) + cour_credit.append(credit) + cour_division.append(division) + cour_num.append(number_class) + cour_time__location.append(time_location) + + print(f"{number_class} 완료") + + + +for key, value in major_315.items(): + url = "https://infodepot.korea.ac.kr/lecture1/lecsubjectPlanViewNew.jsp?year=2024&term=2R&grad_cd=0136&col_cd=9999&dept_cd="+ value +"&cour_cd=" + key + '315' + "&cour_cls=" + '00' + "&" + html = req.urlopen(url) + doc = BeautifulSoup(html,"html.parser") + h3_tag = doc.find('h3') + + if (not h3_tag) or not h3_tag.string or len(h3_tag.string) == 19: + print('no site') + continue + + try: + rows = doc.find(class_="tbl_view").tbody.find_all('tr') + #학점 + credit = rows[0].find_all('td')[1].text.strip() + #이수구분 + division = rows[2].find_all('td')[0].text.strip() + #학수번호-분반 + number_class = rows[1].find_all('td')[0].text.strip() + #강의시간표 및 장소 + time_location = rows[3].find_all('td')[1].text.strip() + #과목명 + title = rows[4].find_all('td')[0].text.strip() + #교수명 + prof = doc.find(class_="bottom_view").find_all('tr')[0].find_all('td')[0].text.strip() + + except Exception as e: + print(f"Error parsing {url}: {e}") + time = None + prof = None + course_credit = None + course_division = None + course_code_sec = None + course_schedule_location = None + + cour_prof.append(prof) + # cour_number = f'GEST{str(num).zfill(3)}-{str(cour_cls).zfill(2)}' + cour_name.append(title) + cour_credit.append(credit) + cour_division.append(division) + cour_num.append(number_class) + cour_time__location.append(time_location) + + print(f"{number_class} 완료") + +# 00 +major_105_107 = { 'POLI':'0199'} +major_212_214_218 = { 'EMLA':'5672'} +major_211_310 = {'FNEG':'5046'} +major_201_301 = {'MUKE':'5753'} +major_202_303 = {'UNIP':'6463'} +major_300_301_302 = { 'HMCI':'6094'} +major_315_414 = { 'LESF':'4425'} +major_301_401_402 = {'DTPR':'7283'} +major_304_402 = {'FADM':'4638'} + +#01 +major_01_202_204 = {'GEMS':'3653'} +for key, value in major_01_202_204.items(): + for num in [202, 204]: + url = "https://infodepot.korea.ac.kr/lecture1/lecsubjectPlanViewNew.jsp?year=2024&term=2R&grad_cd=0136&col_cd=9999&dept_cd="+ value +"&cour_cd=" + key + str(num) + "&cour_cls=" + '01' + "&" + html = req.urlopen(url) + doc = BeautifulSoup(html,"html.parser") + h3_tag = doc.find('h3') + + if (not h3_tag) or not h3_tag.string or len(h3_tag.string) == 19: + print('no site') + continue + + try: + rows = doc.find(class_="tbl_view").tbody.find_all('tr') + #학점 + credit = rows[0].find_all('td')[1].text.strip() + #이수구분 + division = rows[2].find_all('td')[0].text.strip() + #학수번호-분반 + number_class = rows[1].find_all('td')[0].text.strip() + #강의시간표 및 장소 + time_location = rows[3].find_all('td')[1].text.strip() + #과목명 + title = rows[4].find_all('td')[0].text.strip() + #교수명 + prof = doc.find(class_="bottom_view").find_all('tr')[0].find_all('td')[0].text.strip() + + except Exception as e: + print(f"Error parsing {url}: {e}") + time = None + prof = None + course_credit = None + course_division = None + course_code_sec = None + course_schedule_location = None + + cour_prof.append(prof) + # cour_number = f'GEST{str(num).zfill(3)}-{str(cour_cls).zfill(2)}' + cour_name.append(title) + cour_credit.append(credit) + cour_division.append(division) + cour_num.append(number_class) + cour_time__location.append(time_location) + + print(f"{number_class} 완료") + + +for key, value in major_105_107.items(): + for num in [105, 107]: + url = "https://infodepot.korea.ac.kr/lecture1/lecsubjectPlanViewNew.jsp?year=2024&term=2R&grad_cd=0136&col_cd=9999&dept_cd="+ value +"&cour_cd=" + key + str(num) + "&cour_cls=" + '00' + "&" + html = req.urlopen(url) + doc = BeautifulSoup(html,"html.parser") + h3_tag = doc.find('h3') + + if (not h3_tag) or not h3_tag.string or len(h3_tag.string) == 19: + print('no site') + continue + + try: + rows = doc.find(class_="tbl_view").tbody.find_all('tr') + #학점 + credit = rows[0].find_all('td')[1].text.strip() + #이수구분 + division = rows[2].find_all('td')[0].text.strip() + #학수번호-분반 + number_class = rows[1].find_all('td')[0].text.strip() + #강의시간표 및 장소 + time_location = rows[3].find_all('td')[1].text.strip() + #과목명 + title = rows[4].find_all('td')[0].text.strip() + #교수명 + prof = doc.find(class_="bottom_view").find_all('tr')[0].find_all('td')[0].text.strip() + + except Exception as e: + print(f"Error parsing {url}: {e}") + time = None + prof = None + course_credit = None + course_division = None + course_code_sec = None + course_schedule_location = None + + cour_prof.append(prof) + # cour_number = f'GEST{str(num).zfill(3)}-{str(cour_cls).zfill(2)}' + cour_name.append(title) + cour_credit.append(credit) + cour_division.append(division) + cour_num.append(number_class) + cour_time__location.append(time_location) + + print(f"{number_class} 완료") + +for key, value in major_212_214_218.items(): + for num in [212, 214, 218]: + url = "https://infodepot.korea.ac.kr/lecture1/lecsubjectPlanViewNew.jsp?year=2024&term=2R&grad_cd=0136&col_cd=9999&dept_cd="+ value +"&cour_cd=" + key + str(num) + "&cour_cls=" + '00' + "&" + html = req.urlopen(url) + doc = BeautifulSoup(html,"html.parser") + h3_tag = doc.find('h3') + + if (not h3_tag) or not h3_tag.string or len(h3_tag.string) == 19: + print('no site') + continue + + try: + rows = doc.find(class_="tbl_view").tbody.find_all('tr') + #학점 + credit = rows[0].find_all('td')[1].text.strip() + #이수구분 + division = rows[2].find_all('td')[0].text.strip() + #학수번호-분반 + number_class = rows[1].find_all('td')[0].text.strip() + #강의시간표 및 장소 + time_location = rows[3].find_all('td')[1].text.strip() + #과목명 + title = rows[4].find_all('td')[0].text.strip() + #교수명 + prof = doc.find(class_="bottom_view").find_all('tr')[0].find_all('td')[0].text.strip() + + except Exception as e: + print(f"Error parsing {url}: {e}") + time = None + prof = None + course_credit = None + course_division = None + course_code_sec = None + course_schedule_location = None + + cour_prof.append(prof) + # cour_number = f'GEST{str(num).zfill(3)}-{str(cour_cls).zfill(2)}' + cour_name.append(title) + cour_credit.append(credit) + cour_division.append(division) + cour_num.append(number_class) + cour_time__location.append(time_location) + + print(f"{number_class} 완료") + +for key, value in major_211_310.items(): + for num in [211, 310]: + url = "https://infodepot.korea.ac.kr/lecture1/lecsubjectPlanViewNew.jsp?year=2024&term=2R&grad_cd=0136&col_cd=9999&dept_cd="+ value +"&cour_cd=" + key + str(num) + "&cour_cls=" + '00' + "&" + html = req.urlopen(url) + doc = BeautifulSoup(html,"html.parser") + h3_tag = doc.find('h3') + + if (not h3_tag) or not h3_tag.string or len(h3_tag.string) == 19: + print('no site') + continue + + try: + rows = doc.find(class_="tbl_view").tbody.find_all('tr') + #학점 + credit = rows[0].find_all('td')[1].text.strip() + #이수구분 + division = rows[2].find_all('td')[0].text.strip() + #학수번호-분반 + number_class = rows[1].find_all('td')[0].text.strip() + #강의시간표 및 장소 + time_location = rows[3].find_all('td')[1].text.strip() + #과목명 + title = rows[4].find_all('td')[0].text.strip() + #교수명 + prof = doc.find(class_="bottom_view").find_all('tr')[0].find_all('td')[0].text.strip() + + except Exception as e: + print(f"Error parsing {url}: {e}") + time = None + prof = None + course_credit = None + course_division = None + course_code_sec = None + course_schedule_location = None + + cour_prof.append(prof) + # cour_number = f'GEST{str(num).zfill(3)}-{str(cour_cls).zfill(2)}' + cour_name.append(title) + cour_credit.append(credit) + cour_division.append(division) + cour_num.append(number_class) + cour_time__location.append(time_location) + + print(f"{number_class} 완료") + +for key, value in major_201_301.items(): + for num in [201, 301]: + url = "https://infodepot.korea.ac.kr/lecture1/lecsubjectPlanViewNew.jsp?year=2024&term=2R&grad_cd=0136&col_cd=9999&dept_cd="+ value +"&cour_cd=" + key + str(num) + "&cour_cls=" + '00' + "&" + html = req.urlopen(url) + doc = BeautifulSoup(html,"html.parser") + h3_tag = doc.find('h3') + + if (not h3_tag) or not h3_tag.string or len(h3_tag.string) == 19: + print('no site') + continue + + try: + rows = doc.find(class_="tbl_view").tbody.find_all('tr') + #학점 + credit = rows[0].find_all('td')[1].text.strip() + #이수구분 + division = rows[2].find_all('td')[0].text.strip() + #학수번호-분반 + number_class = rows[1].find_all('td')[0].text.strip() + #강의시간표 및 장소 + time_location = rows[3].find_all('td')[1].text.strip() + #과목명 + title = rows[4].find_all('td')[0].text.strip() + #교수명 + prof = doc.find(class_="bottom_view").find_all('tr')[0].find_all('td')[0].text.strip() + + except Exception as e: + print(f"Error parsing {url}: {e}") + time = None + prof = None + course_credit = None + course_division = None + course_code_sec = None + course_schedule_location = None + + cour_prof.append(prof) + # cour_number = f'GEST{str(num).zfill(3)}-{str(cour_cls).zfill(2)}' + cour_name.append(title) + cour_credit.append(credit) + cour_division.append(division) + cour_num.append(number_class) + cour_time__location.append(time_location) + + print(f"{number_class} 완료") + +for key, value in major_202_303.items(): + for num in [202, 303]: + url = "https://infodepot.korea.ac.kr/lecture1/lecsubjectPlanViewNew.jsp?year=2024&term=2R&grad_cd=0136&col_cd=9999&dept_cd="+ value +"&cour_cd=" + key + str(num) + "&cour_cls=" + '00' + "&" + html = req.urlopen(url) + doc = BeautifulSoup(html,"html.parser") + h3_tag = doc.find('h3') + + if (not h3_tag) or not h3_tag.string or len(h3_tag.string) == 19: + print('no site') + continue + + try: + rows = doc.find(class_="tbl_view").tbody.find_all('tr') + #학점 + credit = rows[0].find_all('td')[1].text.strip() + #이수구분 + division = rows[2].find_all('td')[0].text.strip() + #학수번호-분반 + number_class = rows[1].find_all('td')[0].text.strip() + #강의시간표 및 장소 + time_location = rows[3].find_all('td')[1].text.strip() + #과목명 + title = rows[4].find_all('td')[0].text.strip() + #교수명 + prof = doc.find(class_="bottom_view").find_all('tr')[0].find_all('td')[0].text.strip() + + except Exception as e: + print(f"Error parsing {url}: {e}") + time = None + prof = None + course_credit = None + course_division = None + course_code_sec = None + course_schedule_location = None + + cour_prof.append(prof) + # cour_number = f'GEST{str(num).zfill(3)}-{str(cour_cls).zfill(2)}' + cour_name.append(title) + cour_credit.append(credit) + cour_division.append(division) + cour_num.append(number_class) + cour_time__location.append(time_location) + + print(f"{number_class} 완료") + +for key, value in major_300_301_302.items(): + for num in [300, 301, 302]: + url = "https://infodepot.korea.ac.kr/lecture1/lecsubjectPlanViewNew.jsp?year=2024&term=2R&grad_cd=0136&col_cd=9999&dept_cd="+ value +"&cour_cd=" + key + str(num) + "&cour_cls=" + '00' + "&" + html = req.urlopen(url) + doc = BeautifulSoup(html,"html.parser") + h3_tag = doc.find('h3') + + if (not h3_tag) or not h3_tag.string or len(h3_tag.string) == 19: + print('no site') + continue + + try: + rows = doc.find(class_="tbl_view").tbody.find_all('tr') + #학점 + credit = rows[0].find_all('td')[1].text.strip() + #이수구분 + division = rows[2].find_all('td')[0].text.strip() + #학수번호-분반 + number_class = rows[1].find_all('td')[0].text.strip() + #강의시간표 및 장소 + time_location = rows[3].find_all('td')[1].text.strip() + #과목명 + title = rows[4].find_all('td')[0].text.strip() + #교수명 + prof = doc.find(class_="bottom_view").find_all('tr')[0].find_all('td')[0].text.strip() + + except Exception as e: + print(f"Error parsing {url}: {e}") + time = None + prof = None + course_credit = None + course_division = None + course_code_sec = None + course_schedule_location = None + + cour_prof.append(prof) + # cour_number = f'GEST{str(num).zfill(3)}-{str(cour_cls).zfill(2)}' + cour_name.append(title) + cour_credit.append(credit) + cour_division.append(division) + cour_num.append(number_class) + cour_time__location.append(time_location) + + print(f"{number_class} 완료") + +for key, value in major_315_414.items(): + for num in [315, 414]: + url = "https://infodepot.korea.ac.kr/lecture1/lecsubjectPlanViewNew.jsp?year=2024&term=2R&grad_cd=0136&col_cd=9999&dept_cd="+ value +"&cour_cd=" + key + str(num) + "&cour_cls=" + '00' + "&" + html = req.urlopen(url) + doc = BeautifulSoup(html,"html.parser") + h3_tag = doc.find('h3') + + if (not h3_tag) or not h3_tag.string or len(h3_tag.string) == 19: + print('no site') + continue + + try: + rows = doc.find(class_="tbl_view").tbody.find_all('tr') + #학점 + credit = rows[0].find_all('td')[1].text.strip() + #이수구분 + division = rows[2].find_all('td')[0].text.strip() + #학수번호-분반 + number_class = rows[1].find_all('td')[0].text.strip() + #강의시간표 및 장소 + time_location = rows[3].find_all('td')[1].text.strip() + #과목명 + title = rows[4].find_all('td')[0].text.strip() + #교수명 + prof = doc.find(class_="bottom_view").find_all('tr')[0].find_all('td')[0].text.strip() + + except Exception as e: + print(f"Error parsing {url}: {e}") + time = None + prof = None + course_credit = None + course_division = None + course_code_sec = None + course_schedule_location = None + + cour_prof.append(prof) + # cour_number = f'GEST{str(num).zfill(3)}-{str(cour_cls).zfill(2)}' + cour_name.append(title) + cour_credit.append(credit) + cour_division.append(division) + cour_num.append(number_class) + cour_time__location.append(time_location) + + print(f"{number_class} 완료") + +for key, value in major_301_401_402.items(): + for num in [301, 401, 402]: + url = "https://infodepot.korea.ac.kr/lecture1/lecsubjectPlanViewNew.jsp?year=2024&term=2R&grad_cd=0136&col_cd=9999&dept_cd="+ value +"&cour_cd=" + key + str(num) + "&cour_cls=" + '00' + "&" + html = req.urlopen(url) + doc = BeautifulSoup(html,"html.parser") + h3_tag = doc.find('h3') + + if (not h3_tag) or not h3_tag.string or len(h3_tag.string) == 19: + print('no site') + continue + + try: + rows = doc.find(class_="tbl_view").tbody.find_all('tr') + #학점 + credit = rows[0].find_all('td')[1].text.strip() + #이수구분 + division = rows[2].find_all('td')[0].text.strip() + #학수번호-분반 + number_class = rows[1].find_all('td')[0].text.strip() + #강의시간표 및 장소 + time_location = rows[3].find_all('td')[1].text.strip() + #과목명 + title = rows[4].find_all('td')[0].text.strip() + #교수명 + prof = doc.find(class_="bottom_view").find_all('tr')[0].find_all('td')[0].text.strip() + + except Exception as e: + print(f"Error parsing {url}: {e}") + time = None + prof = None + course_credit = None + course_division = None + course_code_sec = None + course_schedule_location = None + + cour_prof.append(prof) + # cour_number = f'GEST{str(num).zfill(3)}-{str(cour_cls).zfill(2)}' + cour_name.append(title) + cour_credit.append(credit) + cour_division.append(division) + cour_num.append(number_class) + cour_time__location.append(time_location) + + print(f"{number_class} 완료") + +for key, value in major_304_402.items(): + for num in [304, 402]: + url = "https://infodepot.korea.ac.kr/lecture1/lecsubjectPlanViewNew.jsp?year=2024&term=2R&grad_cd=0136&col_cd=9999&dept_cd="+ value +"&cour_cd=" + key + str(num) + "&cour_cls=" + '00' + "&" + html = req.urlopen(url) + doc = BeautifulSoup(html,"html.parser") + h3_tag = doc.find('h3') + + if (not h3_tag) or not h3_tag.string or len(h3_tag.string) == 19: + print('no site') + continue + + try: + rows = doc.find(class_="tbl_view").tbody.find_all('tr') + #학점 + credit = rows[0].find_all('td')[1].text.strip() + #이수구분 + division = rows[2].find_all('td')[0].text.strip() + #학수번호-분반 + number_class = rows[1].find_all('td')[0].text.strip() + #강의시간표 및 장소 + time_location = rows[3].find_all('td')[1].text.strip() + #과목명 + title = rows[4].find_all('td')[0].text.strip() + #교수명 + prof = doc.find(class_="bottom_view").find_all('tr')[0].find_all('td')[0].text.strip() + + except Exception as e: + print(f"Error parsing {url}: {e}") + time = None + prof = None + course_credit = None + course_division = None + course_code_sec = None + course_schedule_location = None + + cour_prof.append(prof) + # cour_number = f'GEST{str(num).zfill(3)}-{str(cour_cls).zfill(2)}' + cour_name.append(title) + cour_credit.append(credit) + cour_division.append(division) + cour_num.append(number_class) + cour_time__location.append(time_location) + + print(f"{number_class} 완료") + + +# 데이터프레임으로 변환 및 저장 +df = pd.DataFrame({ + '학수번호-분반': cour_num, + '과목명': cour_name, + '교수명': cour_prof, + '학점': cour_credit, + '이수구분': cour_division, + '강의시간표 및 장소': cour_time__location +}) + +# 데이터프레임을 CSV 파일로 저장 +df.to_csv('전공10.csv', index=False, encoding='utf-8-sig') +print("CSV 파일로 저장 완료") \ No newline at end of file diff --git "a/\355\201\254\353\241\244\353\247\201 \354\275\224\353\223\234/\354\240\204\352\263\265re11.py" "b/\355\201\254\353\241\244\353\247\201 \354\275\224\353\223\234/\354\240\204\352\263\265re11.py" new file mode 100644 index 0000000..6bbe38a --- /dev/null +++ "b/\355\201\254\353\241\244\353\247\201 \354\275\224\353\223\234/\354\240\204\352\263\265re11.py" @@ -0,0 +1,438 @@ +import urllib.request as req +from bs4 import BeautifulSoup +import pandas as pd + +#학수번호 - 분반 +cour_num = [] +#과목명 +cour_name = [] +#교수명 +cour_prof = [] +#학점 +cour_credit = [] +#이수구분 +cour_division = [] +#강의시간 및 장소 +cour_time__location = [] + + + +for num in [3]: + for cour_cls in range(0, 6): + url = "https://infodepot.korea.ac.kr/lecture1/lecsubjectPlanViewNew.jsp?year=2024&term=2R&grad_cd=0136&col_cd=9999&dept_cd="+ '0153' +"&cour_cd=" + 'GERM' + str(num).zfill(3) + "&cour_cls=" + str(cour_cls).zfill(2) + "&" + html = req.urlopen(url) + doc = BeautifulSoup(html,"html.parser") + h3_tag = doc.find('h3') + + if (not h3_tag) or not h3_tag.string or len(h3_tag.string) == 19: + print('no site') + continue + + try: + rows = doc.find(class_="tbl_view").tbody.find_all('tr') + #학점 + credit = rows[0].find_all('td')[1].text.strip() + #이수구분 + division = rows[2].find_all('td')[0].text.strip() + #학수번호-분반 + number_class = rows[1].find_all('td')[0].text.strip() + #강의시간표 및 장소 + time_location = rows[3].find_all('td')[1].text.strip() + #과목명 + title = rows[4].find_all('td')[0].text.strip() + #교수명 + prof = doc.find(class_="bottom_view").find_all('tr')[0].find_all('td')[0].text.strip() + + except Exception as e: + print(f"Error parsing {url}: {e}") + time = None + prof = None + course_credit = None + course_division = None + course_code_sec = None + course_schedule_location = None + + cour_prof.append(prof) + # cour_number = f'GEST{str(num).zfill(3)}-{str(cour_cls).zfill(2)}' + cour_name.append(title) + cour_credit.append(credit) + cour_division.append(division) + cour_num.append(number_class) + cour_time__location.append(time_location) + + print(f"{number_class} 완료") + +for num in [151]: + for cour_cls in range(0, 3): + url = "https://infodepot.korea.ac.kr/lecture1/lecsubjectPlanViewNew.jsp?year=2024&term=2R&grad_cd=0136&col_cd=9999&dept_cd="+ '0203' +"&cour_cd=" + 'PAPP' + str(num).zfill(3) + "&cour_cls=" + str(cour_cls).zfill(2) + "&" + html = req.urlopen(url) + doc = BeautifulSoup(html,"html.parser") + h3_tag = doc.find('h3') + + if (not h3_tag) or not h3_tag.string or len(h3_tag.string) == 19: + print('no site') + continue + + try: + rows = doc.find(class_="tbl_view").tbody.find_all('tr') + #학점 + credit = rows[0].find_all('td')[1].text.strip() + #이수구분 + division = rows[2].find_all('td')[0].text.strip() + #학수번호-분반 + number_class = rows[1].find_all('td')[0].text.strip() + #강의시간표 및 장소 + time_location = rows[3].find_all('td')[1].text.strip() + #과목명 + title = rows[4].find_all('td')[0].text.strip() + #교수명 + prof = doc.find(class_="bottom_view").find_all('tr')[0].find_all('td')[0].text.strip() + + except Exception as e: + print(f"Error parsing {url}: {e}") + time = None + prof = None + course_credit = None + course_division = None + course_code_sec = None + course_schedule_location = None + + cour_prof.append(prof) + # cour_number = f'GEST{str(num).zfill(3)}-{str(cour_cls).zfill(2)}' + cour_name.append(title) + cour_credit.append(credit) + cour_division.append(division) + cour_num.append(number_class) + cour_time__location.append(time_location) + + print(f"{number_class} 완료") + +for num in [110]: + for cour_cls in range(1, 4): + url = "https://infodepot.korea.ac.kr/lecture1/lecsubjectPlanViewNew.jsp?year=2024&term=2R&grad_cd=0136&col_cd=9999&dept_cd="+ '6565' +"&cour_cd=" + 'PSYC' + str(num).zfill(3) + "&cour_cls=" + str(cour_cls).zfill(2) + "&" + html = req.urlopen(url) + doc = BeautifulSoup(html,"html.parser") + h3_tag = doc.find('h3') + + if (not h3_tag) or not h3_tag.string or len(h3_tag.string) == 19: + print('no site') + continue + + try: + rows = doc.find(class_="tbl_view").tbody.find_all('tr') + #학점 + credit = rows[0].find_all('td')[1].text.strip() + #이수구분 + division = rows[2].find_all('td')[0].text.strip() + #학수번호-분반 + number_class = rows[1].find_all('td')[0].text.strip() + #강의시간표 및 장소 + time_location = rows[3].find_all('td')[1].text.strip() + #과목명 + title = rows[4].find_all('td')[0].text.strip() + #교수명 + prof = doc.find(class_="bottom_view").find_all('tr')[0].find_all('td')[0].text.strip() + + except Exception as e: + print(f"Error parsing {url}: {e}") + time = None + prof = None + course_credit = None + course_division = None + course_code_sec = None + course_schedule_location = None + + cour_prof.append(prof) + # cour_number = f'GEST{str(num).zfill(3)}-{str(cour_cls).zfill(2)}' + cour_name.append(title) + cour_credit.append(credit) + cour_division.append(division) + cour_num.append(number_class) + cour_time__location.append(time_location) + + print(f"{number_class} 완료") + +for num in [152, 154]: + for cour_cls in range(1, 5): + url = "https://infodepot.korea.ac.kr/lecture1/lecsubjectPlanViewNew.jsp?year=2024&term=2R&grad_cd=0136&col_cd=9999&dept_cd="+ '0215' +"&cour_cd=" + 'EAES' + str(num).zfill(3) + "&cour_cls=" + str(cour_cls).zfill(2) + "&" + html = req.urlopen(url) + doc = BeautifulSoup(html,"html.parser") + h3_tag = doc.find('h3') + + if (not h3_tag) or not h3_tag.string or len(h3_tag.string) == 19: + print('no site') + continue + + try: + rows = doc.find(class_="tbl_view").tbody.find_all('tr') + #학점 + credit = rows[0].find_all('td')[1].text.strip() + #이수구분 + division = rows[2].find_all('td')[0].text.strip() + #학수번호-분반 + number_class = rows[1].find_all('td')[0].text.strip() + #강의시간표 및 장소 + time_location = rows[3].find_all('td')[1].text.strip() + #과목명 + title = rows[4].find_all('td')[0].text.strip() + #교수명 + prof = doc.find(class_="bottom_view").find_all('tr')[0].find_all('td')[0].text.strip() + + except Exception as e: + print(f"Error parsing {url}: {e}") + time = None + prof = None + course_credit = None + course_division = None + course_code_sec = None + course_schedule_location = None + + cour_prof.append(prof) + # cour_number = f'GEST{str(num).zfill(3)}-{str(cour_cls).zfill(2)}' + cour_name.append(title) + cour_credit.append(credit) + cour_division.append(division) + cour_num.append(number_class) + cour_time__location.append(time_location) + + print(f"{number_class} 완료") + +for num in [152, 156]: + for cour_cls in range(1, 19): + url = "https://infodepot.korea.ac.kr/lecture1/lecsubjectPlanViewNew.jsp?year=2024&term=2R&grad_cd=0136&col_cd=9999&dept_cd="+ '4653' +"&cour_cd=" + 'LIET' + str(num).zfill(3) + "&cour_cls=" + str(cour_cls).zfill(2) + "&" + html = req.urlopen(url) + doc = BeautifulSoup(html,"html.parser") + h3_tag = doc.find('h3') + + if (not h3_tag) or not h3_tag.string or len(h3_tag.string) == 19: + print('no site') + continue + + try: + rows = doc.find(class_="tbl_view").tbody.find_all('tr') + #학점 + credit = rows[0].find_all('td')[1].text.strip() + #이수구분 + division = rows[2].find_all('td')[0].text.strip() + #학수번호-분반 + number_class = rows[1].find_all('td')[0].text.strip() + #강의시간표 및 장소 + time_location = rows[3].find_all('td')[1].text.strip() + #과목명 + title = rows[4].find_all('td')[0].text.strip() + #교수명 + prof = doc.find(class_="bottom_view").find_all('tr')[0].find_all('td')[0].text.strip() + + except Exception as e: + print(f"Error parsing {url}: {e}") + time = None + prof = None + course_credit = None + course_division = None + course_code_sec = None + course_schedule_location = None + + cour_prof.append(prof) + # cour_number = f'GEST{str(num).zfill(3)}-{str(cour_cls).zfill(2)}' + cour_name.append(title) + cour_credit.append(credit) + cour_division.append(division) + cour_num.append(number_class) + cour_time__location.append(time_location) + + print(f"{number_class} 완료") + +for num in [150, 152, 154]: + for cour_cls in range(0,26): + url = "https://infodepot.korea.ac.kr/lecture1/lecsubjectPlanViewNew.jsp?year=2024&term=2R&grad_cd=0136&col_cd=9999&dept_cd="+ '4656' +"&cour_cd=" + 'LIBS' + str(num).zfill(3) + "&cour_cls=" + str(cour_cls).zfill(2) + "&" + html = req.urlopen(url) + doc = BeautifulSoup(html,"html.parser") + h3_tag = doc.find('h3') + + if (not h3_tag) or not h3_tag.string or len(h3_tag.string) == 19: + print('no site') + continue + + try: + rows = doc.find(class_="tbl_view").tbody.find_all('tr') + #학점 + credit = rows[0].find_all('td')[1].text.strip() + #이수구분 + division = rows[2].find_all('td')[0].text.strip() + #학수번호-분반 + number_class = rows[1].find_all('td')[0].text.strip() + #강의시간표 및 장소 + time_location = rows[3].find_all('td')[1].text.strip() + #과목명 + title = rows[4].find_all('td')[0].text.strip() + #교수명 + prof = doc.find(class_="bottom_view").find_all('tr')[0].find_all('td')[0].text.strip() + + except Exception as e: + print(f"Error parsing {url}: {e}") + time = None + prof = None + course_credit = None + course_division = None + course_code_sec = None + course_schedule_location = None + + cour_prof.append(prof) + # cour_number = f'GEST{str(num).zfill(3)}-{str(cour_cls).zfill(2)}' + cour_name.append(title) + cour_credit.append(credit) + cour_division.append(division) + cour_num.append(number_class) + cour_time__location.append(time_location) + + print(f"{number_class} 완료") + +for num in [151, 152, 162]: + for cour_cls in range(0, 53): + url = "https://infodepot.korea.ac.kr/lecture1/lecsubjectPlanViewNew.jsp?year=2024&term=2R&grad_cd=0136&col_cd=9999&dept_cd="+ '0212' +"&cour_cd=" + 'PHYS' + str(num).zfill(3) + "&cour_cls=" + str(cour_cls).zfill(2) + "&" + html = req.urlopen(url) + doc = BeautifulSoup(html,"html.parser") + h3_tag = doc.find('h3') + + if (not h3_tag) or not h3_tag.string or len(h3_tag.string) == 19: + print('no site') + continue + + try: + rows = doc.find(class_="tbl_view").tbody.find_all('tr') + #학점 + credit = rows[0].find_all('td')[1].text.strip() + #이수구분 + division = rows[2].find_all('td')[0].text.strip() + #학수번호-분반 + number_class = rows[1].find_all('td')[0].text.strip() + #강의시간표 및 장소 + time_location = rows[3].find_all('td')[1].text.strip() + #과목명 + title = rows[4].find_all('td')[0].text.strip() + #교수명 + prof = doc.find(class_="bottom_view").find_all('tr')[0].find_all('td')[0].text.strip() + + except Exception as e: + print(f"Error parsing {url}: {e}") + time = None + prof = None + course_credit = None + course_division = None + course_code_sec = None + course_schedule_location = None + + cour_prof.append(prof) + # cour_number = f'GEST{str(num).zfill(3)}-{str(cour_cls).zfill(2)}' + cour_name.append(title) + cour_credit.append(credit) + cour_division.append(division) + cour_num.append(number_class) + cour_time__location.append(time_location) + + print(f"{number_class} 완료") + +for num in [161, 162, 166]: + for cour_cls in range(0, 24): + url = "https://infodepot.korea.ac.kr/lecture1/lecsubjectPlanViewNew.jsp?year=2024&term=2R&grad_cd=0136&col_cd=9999&dept_cd="+ '0211' +"&cour_cd=" + 'MATH' + str(num).zfill(3) + "&cour_cls=" + str(cour_cls).zfill(2) + "&" + html = req.urlopen(url) + doc = BeautifulSoup(html,"html.parser") + h3_tag = doc.find('h3') + + if (not h3_tag) or not h3_tag.string or len(h3_tag.string) == 19: + print('no site') + continue + + try: + rows = doc.find(class_="tbl_view").tbody.find_all('tr') + #학점 + credit = rows[0].find_all('td')[1].text.strip() + #이수구분 + division = rows[2].find_all('td')[0].text.strip() + #학수번호-분반 + number_class = rows[1].find_all('td')[0].text.strip() + #강의시간표 및 장소 + time_location = rows[3].find_all('td')[1].text.strip() + #과목명 + title = rows[4].find_all('td')[0].text.strip() + #교수명 + prof = doc.find(class_="bottom_view").find_all('tr')[0].find_all('td')[0].text.strip() + + except Exception as e: + print(f"Error parsing {url}: {e}") + time = None + prof = None + course_credit = None + course_division = None + course_code_sec = None + course_schedule_location = None + + cour_prof.append(prof) + # cour_number = f'GEST{str(num).zfill(3)}-{str(cour_cls).zfill(2)}' + cour_name.append(title) + cour_credit.append(credit) + cour_division.append(division) + cour_num.append(number_class) + cour_time__location.append(time_location) + + print(f"{number_class} 완료") + +for num in [401, 402, 403]: + for cour_cls in range(0, 4): + url = "https://infodepot.korea.ac.kr/lecture1/lecsubjectPlanViewNew.jsp?year=2024&term=2R&grad_cd=0136&col_cd=9999&dept_cd="+ '4067' +"&cour_cd=" + 'COLA' + str(num).zfill(3) + "&cour_cls=" + str(cour_cls).zfill(2) + "&" + html = req.urlopen(url) + doc = BeautifulSoup(html,"html.parser") + h3_tag = doc.find('h3') + + if (not h3_tag) or not h3_tag.string or len(h3_tag.string) == 19: + print('no site') + continue + + try: + rows = doc.find(class_="tbl_view").tbody.find_all('tr') + #학점 + credit = rows[0].find_all('td')[1].text.strip() + #이수구분 + division = rows[2].find_all('td')[0].text.strip() + #학수번호-분반 + number_class = rows[1].find_all('td')[0].text.strip() + #강의시간표 및 장소 + time_location = rows[3].find_all('td')[1].text.strip() + #과목명 + title = rows[4].find_all('td')[0].text.strip() + #교수명 + prof = doc.find(class_="bottom_view").find_all('tr')[0].find_all('td')[0].text.strip() + + except Exception as e: + print(f"Error parsing {url}: {e}") + time = None + prof = None + course_credit = None + course_division = None + course_code_sec = None + course_schedule_location = None + + cour_prof.append(prof) + # cour_number = f'GEST{str(num).zfill(3)}-{str(cour_cls).zfill(2)}' + cour_name.append(title) + cour_credit.append(credit) + cour_division.append(division) + cour_num.append(number_class) + cour_time__location.append(time_location) + + print(f"{number_class} 완료") + + + # 데이터프레임으로 변환 및 저장 +df = pd.DataFrame({ + '학수번호-분반': cour_num, + '과목명': cour_name, + '교수명': cour_prof, + '학점': cour_credit, + '이수구분': cour_division, + '강의시간표 및 장소': cour_time__location +}) + +# 데이터프레임을 CSV 파일로 저장 +df.to_csv('전공11.csv', index=False, encoding='utf-8-sig') +print("CSV 파일로 저장 완료") \ No newline at end of file diff --git "a/\355\201\254\353\241\244\353\247\201 \354\275\224\353\223\234/\354\240\204\352\263\265re8.py" "b/\355\201\254\353\241\244\353\247\201 \354\275\224\353\223\234/\354\240\204\352\263\265re8.py" new file mode 100644 index 0000000..4af0581 --- /dev/null +++ "b/\355\201\254\353\241\244\353\247\201 \354\275\224\353\223\234/\354\240\204\352\263\265re8.py" @@ -0,0 +1,602 @@ +import urllib.request as req +from bs4 import BeautifulSoup +import pandas as pd + +#학수번호 - 분반 +cour_num = [] +#과목명 +cour_name = [] +#교수명 +cour_prof = [] +#학점 +cour_credit = [] +#이수구분 +cour_division = [] +#강의시간 및 장소 +cour_time__location = [] + + +major04_000_500 = { 'PHIL':'0147' , 'HOKA':'0148'} +major08_000_500 = {'BUSS' : '0142'} +major05_100_400 = { 'JURA':'6459'} +major04_100_600 = { 'ARCH':'4887'} +major00_200_300 = { 'GLKS':'7037' } +major04_200_400 = { 'PAPP':'0203', 'LIST':'4719'} + +major02_100_200 = {'SOCI':'0152'} +major06_100_200 = {'SPAN':'0158', 'COLA':'4067'} +major07_100_200 = { 'HOEW':'0803'} +major08_100_200 = {'EGRN': '4065', 'ENGL':'0146', 'CHIN':'0155'} +major111_100_200 = { 'HANM':'0159'} +major130_100_200 = {'CHEM':'0213'} + + + + +for key, value in major04_000_500.items(): + for num in range (0, 500): + for cour_cls in range(0, 5): + url = "https://infodepot.korea.ac.kr/lecture1/lecsubjectPlanViewNew.jsp?year=2024&term=2R&grad_cd=0136&col_cd=9999&dept_cd="+ value +"&cour_cd=" + key + str(num).zfill(3) + "&cour_cls=" + str(cour_cls).zfill(2) + "&" + html = req.urlopen(url) + doc = BeautifulSoup(html,"html.parser") + h3_tag = doc.find('h3') + + if (not h3_tag) or not h3_tag.string or len(h3_tag.string) == 19: + print('no site') + continue + + try: + rows = doc.find(class_="tbl_view").tbody.find_all('tr') + #학점 + credit = rows[0].find_all('td')[1].text.strip() + #이수구분 + division = rows[2].find_all('td')[0].text.strip() + #학수번호-분반 + number_class = rows[1].find_all('td')[0].text.strip() + #강의시간표 및 장소 + time_location = rows[3].find_all('td')[1].text.strip() + #과목명 + title = rows[4].find_all('td')[0].text.strip() + #교수명 + prof = doc.find(class_="bottom_view").find_all('tr')[0].find_all('td')[0].text.strip() + + except Exception as e: + print(f"Error parsing {url}: {e}") + time = None + prof = None + course_credit = None + course_division = None + course_code_sec = None + course_schedule_location = None + + cour_prof.append(prof) + # cour_number = f'GEST{str(num).zfill(3)}-{str(cour_cls).zfill(2)}' + cour_name.append(title) + cour_credit.append(credit) + cour_division.append(division) + cour_num.append(number_class) + cour_time__location.append(time_location) + + print(f"{number_class} 완료") + +for key, value in major08_000_500.items(): + for num in range (0, 500): + for cour_cls in range(0, 9): + url = "https://infodepot.korea.ac.kr/lecture1/lecsubjectPlanViewNew.jsp?year=2024&term=2R&grad_cd=0136&col_cd=9999&dept_cd="+ value +"&cour_cd=" + key + str(num).zfill(3) + "&cour_cls=" + str(cour_cls).zfill(2) + "&" + html = req.urlopen(url) + doc = BeautifulSoup(html,"html.parser") + h3_tag = doc.find('h3') + + if (not h3_tag) or not h3_tag.string or len(h3_tag.string) == 19: + print('no site') + continue + + try: + rows = doc.find(class_="tbl_view").tbody.find_all('tr') + #학점 + credit = rows[0].find_all('td')[1].text.strip() + #이수구분 + division = rows[2].find_all('td')[0].text.strip() + #학수번호-분반 + number_class = rows[1].find_all('td')[0].text.strip() + #강의시간표 및 장소 + time_location = rows[3].find_all('td')[1].text.strip() + #과목명 + title = rows[4].find_all('td')[0].text.strip() + #교수명 + prof = doc.find(class_="bottom_view").find_all('tr')[0].find_all('td')[0].text.strip() + + except Exception as e: + print(f"Error parsing {url}: {e}") + time = None + prof = None + course_credit = None + course_division = None + course_code_sec = None + course_schedule_location = None + + cour_prof.append(prof) + # cour_number = f'GEST{str(num).zfill(3)}-{str(cour_cls).zfill(2)}' + cour_name.append(title) + cour_credit.append(credit) + cour_division.append(division) + cour_num.append(number_class) + cour_time__location.append(time_location) + + print(f"{number_class} 완료") + +for key, value in major05_100_400.items(): + for num in range (100, 400): + for cour_cls in range(0, 6): + url = "https://infodepot.korea.ac.kr/lecture1/lecsubjectPlanViewNew.jsp?year=2024&term=2R&grad_cd=0136&col_cd=9999&dept_cd="+ value +"&cour_cd=" + key + str(num).zfill(3) + "&cour_cls=" + str(cour_cls).zfill(2) + "&" + html = req.urlopen(url) + doc = BeautifulSoup(html,"html.parser") + h3_tag = doc.find('h3') + + if (not h3_tag) or not h3_tag.string or len(h3_tag.string) == 19: + print('no site') + continue + + try: + rows = doc.find(class_="tbl_view").tbody.find_all('tr') + #학점 + credit = rows[0].find_all('td')[1].text.strip() + #이수구분 + division = rows[2].find_all('td')[0].text.strip() + #학수번호-분반 + number_class = rows[1].find_all('td')[0].text.strip() + #강의시간표 및 장소 + time_location = rows[3].find_all('td')[1].text.strip() + #과목명 + title = rows[4].find_all('td')[0].text.strip() + #교수명 + prof = doc.find(class_="bottom_view").find_all('tr')[0].find_all('td')[0].text.strip() + + except Exception as e: + print(f"Error parsing {url}: {e}") + time = None + prof = None + course_credit = None + course_division = None + course_code_sec = None + course_schedule_location = None + + cour_prof.append(prof) + # cour_number = f'GEST{str(num).zfill(3)}-{str(cour_cls).zfill(2)}' + cour_name.append(title) + cour_credit.append(credit) + cour_division.append(division) + cour_num.append(number_class) + cour_time__location.append(time_location) + + print(f"{number_class} 완료") +for key, value in major04_100_600.items(): + for num in range (100, 600): + for cour_cls in range(0, 5): + url = "https://infodepot.korea.ac.kr/lecture1/lecsubjectPlanViewNew.jsp?year=2024&term=2R&grad_cd=0136&col_cd=9999&dept_cd="+ value +"&cour_cd=" + key + str(num).zfill(3) + "&cour_cls=" + str(cour_cls).zfill(2) + "&" + html = req.urlopen(url) + doc = BeautifulSoup(html,"html.parser") + h3_tag = doc.find('h3') + + if (not h3_tag) or not h3_tag.string or len(h3_tag.string) == 19: + print('no site') + continue + + try: + rows = doc.find(class_="tbl_view").tbody.find_all('tr') + #학점 + credit = rows[0].find_all('td')[1].text.strip() + #이수구분 + division = rows[2].find_all('td')[0].text.strip() + #학수번호-분반 + number_class = rows[1].find_all('td')[0].text.strip() + #강의시간표 및 장소 + time_location = rows[3].find_all('td')[1].text.strip() + #과목명 + title = rows[4].find_all('td')[0].text.strip() + #교수명 + prof = doc.find(class_="bottom_view").find_all('tr')[0].find_all('td')[0].text.strip() + + except Exception as e: + print(f"Error parsing {url}: {e}") + time = None + prof = None + course_credit = None + course_division = None + course_code_sec = None + course_schedule_location = None + + cour_prof.append(prof) + # cour_number = f'GEST{str(num).zfill(3)}-{str(cour_cls).zfill(2)}' + cour_name.append(title) + cour_credit.append(credit) + cour_division.append(division) + cour_num.append(number_class) + cour_time__location.append(time_location) + + print(f"{number_class} 완료") + + + +for key, value in major00_200_300.items(): + for num in range (200, 300): + url = "https://infodepot.korea.ac.kr/lecture1/lecsubjectPlanViewNew.jsp?year=2024&term=2R&grad_cd=0136&col_cd=9999&dept_cd="+ value +"&cour_cd=" + key + str(num).zfill(3) + "&cour_cls=" + "00" + "&" + html = req.urlopen(url) + doc = BeautifulSoup(html,"html.parser") + h3_tag = doc.find('h3') + + if (not h3_tag) or not h3_tag.string or len(h3_tag.string) == 19: + print('no site') + continue + + try: + rows = doc.find(class_="tbl_view").tbody.find_all('tr') + #학점 + credit = rows[0].find_all('td')[1].text.strip() + #이수구분 + division = rows[2].find_all('td')[0].text.strip() + #학수번호-분반 + number_class = rows[1].find_all('td')[0].text.strip() + #강의시간표 및 장소 + time_location = rows[3].find_all('td')[1].text.strip() + #과목명 + title = rows[4].find_all('td')[0].text.strip() + #교수명 + prof = doc.find(class_="bottom_view").find_all('tr')[0].find_all('td')[0].text.strip() + + except Exception as e: + print(f"Error parsing {url}: {e}") + time = None + prof = None + course_credit = None + course_division = None + course_code_sec = None + course_schedule_location = None + + cour_prof.append(prof) + # cour_number = f'GEST{str(num).zfill(3)}-{str(cour_cls).zfill(2)}' + cour_name.append(title) + cour_credit.append(credit) + cour_division.append(division) + cour_num.append(number_class) + cour_time__location.append(time_location) + + print(f"{number_class} 완료") + + + +for key, value in major04_200_400.items(): + for num in range (200, 400): + for cour_cls in range(0, 5): + url = "https://infodepot.korea.ac.kr/lecture1/lecsubjectPlanViewNew.jsp?year=2024&term=2R&grad_cd=0136&col_cd=9999&dept_cd="+ value +"&cour_cd=" + key + str(num).zfill(3) + "&cour_cls=" + str(cour_cls).zfill(2) + "&" + html = req.urlopen(url) + doc = BeautifulSoup(html,"html.parser") + h3_tag = doc.find('h3') + + if (not h3_tag) or not h3_tag.string or len(h3_tag.string) == 19: + print('no site') + continue + + try: + rows = doc.find(class_="tbl_view").tbody.find_all('tr') + #학점 + credit = rows[0].find_all('td')[1].text.strip() + #이수구분 + division = rows[2].find_all('td')[0].text.strip() + #학수번호-분반 + number_class = rows[1].find_all('td')[0].text.strip() + #강의시간표 및 장소 + time_location = rows[3].find_all('td')[1].text.strip() + #과목명 + title = rows[4].find_all('td')[0].text.strip() + #교수명 + prof = doc.find(class_="bottom_view").find_all('tr')[0].find_all('td')[0].text.strip() + + except Exception as e: + print(f"Error parsing {url}: {e}") + time = None + prof = None + course_credit = None + course_division = None + course_code_sec = None + course_schedule_location = None + + cour_prof.append(prof) + # cour_number = f'GEST{str(num).zfill(3)}-{str(cour_cls).zfill(2)}' + cour_name.append(title) + cour_credit.append(credit) + cour_division.append(division) + cour_num.append(number_class) + cour_time__location.append(time_location) + + print(f"{number_class} 완료") + + +for key, value in major02_100_200.items(): + for num in range (100, 200): + for cour_cls in range(0, 3): + url = "https://infodepot.korea.ac.kr/lecture1/lecsubjectPlanViewNew.jsp?year=2024&term=2R&grad_cd=0136&col_cd=9999&dept_cd="+ value +"&cour_cd=" + key + str(num).zfill(3) + "&cour_cls=" + str(cour_cls).zfill(2) + "&" + html = req.urlopen(url) + doc = BeautifulSoup(html,"html.parser") + h3_tag = doc.find('h3') + + if (not h3_tag) or not h3_tag.string or len(h3_tag.string) == 19: + print('no site') + continue + + try: + rows = doc.find(class_="tbl_view").tbody.find_all('tr') + #학점 + credit = rows[0].find_all('td')[1].text.strip() + #이수구분 + division = rows[2].find_all('td')[0].text.strip() + #학수번호-분반 + number_class = rows[1].find_all('td')[0].text.strip() + #강의시간표 및 장소 + time_location = rows[3].find_all('td')[1].text.strip() + #과목명 + title = rows[4].find_all('td')[0].text.strip() + #교수명 + prof = doc.find(class_="bottom_view").find_all('tr')[0].find_all('td')[0].text.strip() + + except Exception as e: + print(f"Error parsing {url}: {e}") + time = None + prof = None + course_credit = None + course_division = None + course_code_sec = None + course_schedule_location = None + + cour_prof.append(prof) + # cour_number = f'GEST{str(num).zfill(3)}-{str(cour_cls).zfill(2)}' + cour_name.append(title) + cour_credit.append(credit) + cour_division.append(division) + cour_num.append(number_class) + cour_time__location.append(time_location) + + print(f"{number_class} 완료") +for key, value in major06_100_200.items(): + for num in range (100, 200): + for cour_cls in range(0, 7): + url = "https://infodepot.korea.ac.kr/lecture1/lecsubjectPlanViewNew.jsp?year=2024&term=2R&grad_cd=0136&col_cd=9999&dept_cd="+ value +"&cour_cd=" + key + str(num).zfill(3) + "&cour_cls=" + str(cour_cls).zfill(2) + "&" + html = req.urlopen(url) + doc = BeautifulSoup(html,"html.parser") + h3_tag = doc.find('h3') + + if (not h3_tag) or not h3_tag.string or len(h3_tag.string) == 19: + print('no site') + continue + + try: + rows = doc.find(class_="tbl_view").tbody.find_all('tr') + #학점 + credit = rows[0].find_all('td')[1].text.strip() + #이수구분 + division = rows[2].find_all('td')[0].text.strip() + #학수번호-분반 + number_class = rows[1].find_all('td')[0].text.strip() + #강의시간표 및 장소 + time_location = rows[3].find_all('td')[1].text.strip() + #과목명 + title = rows[4].find_all('td')[0].text.strip() + #교수명 + prof = doc.find(class_="bottom_view").find_all('tr')[0].find_all('td')[0].text.strip() + + except Exception as e: + print(f"Error parsing {url}: {e}") + time = None + prof = None + course_credit = None + course_division = None + course_code_sec = None + course_schedule_location = None + + cour_prof.append(prof) + # cour_number = f'GEST{str(num).zfill(3)}-{str(cour_cls).zfill(2)}' + cour_name.append(title) + cour_credit.append(credit) + cour_division.append(division) + cour_num.append(number_class) + cour_time__location.append(time_location) + + print(f"{number_class} 완료") + +for key, value in major07_100_200.items(): + for num in range (100, 200): + for cour_cls in range(0, 8): + url = "https://infodepot.korea.ac.kr/lecture1/lecsubjectPlanViewNew.jsp?year=2024&term=2R&grad_cd=0136&col_cd=9999&dept_cd="+ value +"&cour_cd=" + key + str(num).zfill(3) + "&cour_cls=" + str(cour_cls).zfill(2) + "&" + html = req.urlopen(url) + doc = BeautifulSoup(html,"html.parser") + h3_tag = doc.find('h3') + + if (not h3_tag) or not h3_tag.string or len(h3_tag.string) == 19: + print('no site') + continue + + try: + rows = doc.find(class_="tbl_view").tbody.find_all('tr') + #학점 + credit = rows[0].find_all('td')[1].text.strip() + #이수구분 + division = rows[2].find_all('td')[0].text.strip() + #학수번호-분반 + number_class = rows[1].find_all('td')[0].text.strip() + #강의시간표 및 장소 + time_location = rows[3].find_all('td')[1].text.strip() + #과목명 + title = rows[4].find_all('td')[0].text.strip() + #교수명 + prof = doc.find(class_="bottom_view").find_all('tr')[0].find_all('td')[0].text.strip() + + except Exception as e: + print(f"Error parsing {url}: {e}") + time = None + prof = None + course_credit = None + course_division = None + course_code_sec = None + course_schedule_location = None + + cour_prof.append(prof) + # cour_number = f'GEST{str(num).zfill(3)}-{str(cour_cls).zfill(2)}' + cour_name.append(title) + cour_credit.append(credit) + cour_division.append(division) + cour_num.append(number_class) + cour_time__location.append(time_location) + + print(f"{number_class} 완료") +for key, value in major08_100_200.items(): + for num in range (100, 200): + for cour_cls in range(0, 9): + url = "https://infodepot.korea.ac.kr/lecture1/lecsubjectPlanViewNew.jsp?year=2024&term=2R&grad_cd=0136&col_cd=9999&dept_cd="+ value +"&cour_cd=" + key + str(num).zfill(3) + "&cour_cls=" + str(cour_cls).zfill(2) + "&" + html = req.urlopen(url) + doc = BeautifulSoup(html,"html.parser") + h3_tag = doc.find('h3') + + if (not h3_tag) or not h3_tag.string or len(h3_tag.string) == 19: + print('no site') + continue + + try: + rows = doc.find(class_="tbl_view").tbody.find_all('tr') + #학점 + credit = rows[0].find_all('td')[1].text.strip() + #이수구분 + division = rows[2].find_all('td')[0].text.strip() + #학수번호-분반 + number_class = rows[1].find_all('td')[0].text.strip() + #강의시간표 및 장소 + time_location = rows[3].find_all('td')[1].text.strip() + #과목명 + title = rows[4].find_all('td')[0].text.strip() + #교수명 + prof = doc.find(class_="bottom_view").find_all('tr')[0].find_all('td')[0].text.strip() + + except Exception as e: + print(f"Error parsing {url}: {e}") + time = None + prof = None + course_credit = None + course_division = None + course_code_sec = None + course_schedule_location = None + + cour_prof.append(prof) + # cour_number = f'GEST{str(num).zfill(3)}-{str(cour_cls).zfill(2)}' + cour_name.append(title) + cour_credit.append(credit) + cour_division.append(division) + cour_num.append(number_class) + cour_time__location.append(time_location) + + print(f"{number_class} 완료") + +for key, value in major111_100_200.items(): + for num in range (100, 200): + for cour_cls in range(1, 12): + url = "https://infodepot.korea.ac.kr/lecture1/lecsubjectPlanViewNew.jsp?year=2024&term=2R&grad_cd=0136&col_cd=9999&dept_cd="+ value +"&cour_cd=" + key + str(num).zfill(3) + "&cour_cls=" + str(cour_cls).zfill(2) + "&" + html = req.urlopen(url) + doc = BeautifulSoup(html,"html.parser") + h3_tag = doc.find('h3') + + if (not h3_tag) or not h3_tag.string or len(h3_tag.string) == 19: + print('no site') + continue + + try: + rows = doc.find(class_="tbl_view").tbody.find_all('tr') + #학점 + credit = rows[0].find_all('td')[1].text.strip() + #이수구분 + division = rows[2].find_all('td')[0].text.strip() + #학수번호-분반 + number_class = rows[1].find_all('td')[0].text.strip() + #강의시간표 및 장소 + time_location = rows[3].find_all('td')[1].text.strip() + #과목명 + title = rows[4].find_all('td')[0].text.strip() + #교수명 + prof = doc.find(class_="bottom_view").find_all('tr')[0].find_all('td')[0].text.strip() + + except Exception as e: + print(f"Error parsing {url}: {e}") + time = None + prof = None + course_credit = None + course_division = None + course_code_sec = None + course_schedule_location = None + + cour_prof.append(prof) + # cour_number = f'GEST{str(num).zfill(3)}-{str(cour_cls).zfill(2)}' + cour_name.append(title) + cour_credit.append(credit) + cour_division.append(division) + cour_num.append(number_class) + cour_time__location.append(time_location) + + print(f"{number_class} 완료") + +for key, value in major130_100_200.items(): + for num in range (100, 200): + for cour_cls in range(1, 31): + url = "https://infodepot.korea.ac.kr/lecture1/lecsubjectPlanViewNew.jsp?year=2024&term=2R&grad_cd=0136&col_cd=9999&dept_cd="+ value +"&cour_cd=" + key + str(num).zfill(3) + "&cour_cls=" + str(cour_cls).zfill(2) + "&" + html = req.urlopen(url) + doc = BeautifulSoup(html,"html.parser") + h3_tag = doc.find('h3') + + if (not h3_tag) or not h3_tag.string or len(h3_tag.string) == 19: + print('no site') + continue + + try: + rows = doc.find(class_="tbl_view").tbody.find_all('tr') + #학점 + credit = rows[0].find_all('td')[1].text.strip() + #이수구분 + division = rows[2].find_all('td')[0].text.strip() + #학수번호-분반 + number_class = rows[1].find_all('td')[0].text.strip() + #강의시간표 및 장소 + time_location = rows[3].find_all('td')[1].text.strip() + #과목명 + title = rows[4].find_all('td')[0].text.strip() + #교수명 + prof = doc.find(class_="bottom_view").find_all('tr')[0].find_all('td')[0].text.strip() + + except Exception as e: + print(f"Error parsing {url}: {e}") + time = None + prof = None + course_credit = None + course_division = None + course_code_sec = None + course_schedule_location = None + + cour_prof.append(prof) + # cour_number = f'GEST{str(num).zfill(3)}-{str(cour_cls).zfill(2)}' + cour_name.append(title) + cour_credit.append(credit) + cour_division.append(division) + cour_num.append(number_class) + cour_time__location.append(time_location) + + print(f"{number_class} 완료") + + +# 데이터프레임으로 변환 및 저장 +df = pd.DataFrame({ + '학수번호-분반': cour_num, + '과목명': cour_name, + '교수명': cour_prof, + '학점': cour_credit, + '이수구분': cour_division, + '강의시간표 및 장소': cour_time__location +}) + +# 데이터프레임을 CSV 파일로 저장 +df.to_csv('전공8.csv', index=False, encoding='utf-8-sig') +print("CSV 파일로 저장 완료") diff --git "a/\355\201\254\353\241\244\353\247\201 \354\275\224\353\223\234/\354\240\204\352\263\265re9.py" "b/\355\201\254\353\241\244\353\247\201 \354\275\224\353\223\234/\354\240\204\352\263\265re9.py" new file mode 100644 index 0000000..39f21f4 --- /dev/null +++ "b/\355\201\254\353\241\244\353\247\201 \354\275\224\353\223\234/\354\240\204\352\263\265re9.py" @@ -0,0 +1,263 @@ +import urllib.request as req +from bs4 import BeautifulSoup +import pandas as pd + +#학수번호 - 분반 +cour_num = [] +#과목명 +cour_name = [] +#교수명 +cour_prof = [] +#학점 +cour_credit = [] +#이수구분 +cour_division = [] +#강의시간 및 장소 +cour_time__location = [] + +major16_800_900 = {'PHEK':'0237'} +major00_100_200 = {'CPSE':'4062', 'KMCE':'5962', 'LALW':'5539'} +major00_300_400 = { 'TEEN':'6544'} +major00_400_500 = { 'DATA':'6725', 'STEP':'5965', 'ITCS' : '5964'} +major00_700_800 = {'PSYC':'6565'} + +for key, value in major16_800_900.items(): + for num in range (800, 900): + for cour_cls in range(1, 7): + url = "https://infodepot.korea.ac.kr/lecture1/lecsubjectPlanViewNew.jsp?year=2024&term=2R&grad_cd=0136&col_cd=9999&dept_cd="+ value +"&cour_cd=" + key + str(num).zfill(3) + "&cour_cls=" + str(cour_cls).zfill(2) + "&" + html = req.urlopen(url) + doc = BeautifulSoup(html,"html.parser") + h3_tag = doc.find('h3') + + if (not h3_tag) or not h3_tag.string or len(h3_tag.string) == 19: + print('no site') + continue + + try: + rows = doc.find(class_="tbl_view").tbody.find_all('tr') + #학점 + credit = rows[0].find_all('td')[1].text.strip() + #이수구분 + division = rows[2].find_all('td')[0].text.strip() + #학수번호-분반 + number_class = rows[1].find_all('td')[0].text.strip() + #강의시간표 및 장소 + time_location = rows[3].find_all('td')[1].text.strip() + #과목명 + title = rows[4].find_all('td')[0].text.strip() + #교수명 + prof = doc.find(class_="bottom_view").find_all('tr')[0].find_all('td')[0].text.strip() + + except Exception as e: + print(f"Error parsing {url}: {e}") + time = None + prof = None + course_credit = None + course_division = None + course_code_sec = None + course_schedule_location = None + + cour_prof.append(prof) + # cour_number = f'GEST{str(num).zfill(3)}-{str(cour_cls).zfill(2)}' + cour_name.append(title) + cour_credit.append(credit) + cour_division.append(division) + cour_num.append(number_class) + cour_time__location.append(time_location) + + print(f"{number_class} 완료") + +for key, value in major00_100_200.items(): + for num in range (100, 200): + url = "https://infodepot.korea.ac.kr/lecture1/lecsubjectPlanViewNew.jsp?year=2024&term=2R&grad_cd=0136&col_cd=9999&dept_cd="+ value +"&cour_cd=" + key + str(num).zfill(3) + "&cour_cls=" + "00" + "&" + html = req.urlopen(url) + doc = BeautifulSoup(html,"html.parser") + h3_tag = doc.find('h3') + + if (not h3_tag) or not h3_tag.string or len(h3_tag.string) == 19: + print('no site') + continue + + try: + rows = doc.find(class_="tbl_view").tbody.find_all('tr') + #학점 + credit = rows[0].find_all('td')[1].text.strip() + #이수구분 + division = rows[2].find_all('td')[0].text.strip() + #학수번호-분반 + number_class = rows[1].find_all('td')[0].text.strip() + #강의시간표 및 장소 + time_location = rows[3].find_all('td')[1].text.strip() + #과목명 + title = rows[4].find_all('td')[0].text.strip() + #교수명 + prof = doc.find(class_="bottom_view").find_all('tr')[0].find_all('td')[0].text.strip() + + except Exception as e: + print(f"Error parsing {url}: {e}") + time = None + prof = None + course_credit = None + course_division = None + course_code_sec = None + course_schedule_location = None + + cour_prof.append(prof) + # cour_number = f'GEST{str(num).zfill(3)}-{str(cour_cls).zfill(2)}' + cour_name.append(title) + cour_credit.append(credit) + cour_division.append(division) + cour_num.append(number_class) + cour_time__location.append(time_location) + + print(f"{number_class} 완료") +for key, value in major00_300_400.items(): + for num in range (300, 400): + url = "https://infodepot.korea.ac.kr/lecture1/lecsubjectPlanViewNew.jsp?year=2024&term=2R&grad_cd=0136&col_cd=9999&dept_cd="+ value +"&cour_cd=" + key + str(num).zfill(3) + "&cour_cls=" + "00" + "&" + html = req.urlopen(url) + doc = BeautifulSoup(html,"html.parser") + h3_tag = doc.find('h3') + + if (not h3_tag) or not h3_tag.string or len(h3_tag.string) == 19: + print('no site') + continue + + try: + rows = doc.find(class_="tbl_view").tbody.find_all('tr') + #학점 + credit = rows[0].find_all('td')[1].text.strip() + #이수구분 + division = rows[2].find_all('td')[0].text.strip() + #학수번호-분반 + number_class = rows[1].find_all('td')[0].text.strip() + #강의시간표 및 장소 + time_location = rows[3].find_all('td')[1].text.strip() + #과목명 + title = rows[4].find_all('td')[0].text.strip() + #교수명 + prof = doc.find(class_="bottom_view").find_all('tr')[0].find_all('td')[0].text.strip() + + except Exception as e: + print(f"Error parsing {url}: {e}") + time = None + prof = None + course_credit = None + course_division = None + course_code_sec = None + course_schedule_location = None + + cour_prof.append(prof) + # cour_number = f'GEST{str(num).zfill(3)}-{str(cour_cls).zfill(2)}' + cour_name.append(title) + cour_credit.append(credit) + cour_division.append(division) + cour_num.append(number_class) + cour_time__location.append(time_location) + + print(f"{number_class} 완료") +for key, value in major00_400_500.items(): + for num in range (400, 500): + url = "https://infodepot.korea.ac.kr/lecture1/lecsubjectPlanViewNew.jsp?year=2024&term=2R&grad_cd=0136&col_cd=9999&dept_cd="+ value +"&cour_cd=" + key + str(num).zfill(3) + "&cour_cls=" + "00" + "&" + html = req.urlopen(url) + doc = BeautifulSoup(html,"html.parser") + h3_tag = doc.find('h3') + + if (not h3_tag) or not h3_tag.string or len(h3_tag.string) == 19: + print('no site') + continue + + try: + rows = doc.find(class_="tbl_view").tbody.find_all('tr') + #학점 + credit = rows[0].find_all('td')[1].text.strip() + #이수구분 + division = rows[2].find_all('td')[0].text.strip() + #학수번호-분반 + number_class = rows[1].find_all('td')[0].text.strip() + #강의시간표 및 장소 + time_location = rows[3].find_all('td')[1].text.strip() + #과목명 + title = rows[4].find_all('td')[0].text.strip() + #교수명 + prof = doc.find(class_="bottom_view").find_all('tr')[0].find_all('td')[0].text.strip() + + except Exception as e: + print(f"Error parsing {url}: {e}") + time = None + prof = None + course_credit = None + course_division = None + course_code_sec = None + course_schedule_location = None + + cour_prof.append(prof) + # cour_number = f'GEST{str(num).zfill(3)}-{str(cour_cls).zfill(2)}' + cour_name.append(title) + cour_credit.append(credit) + cour_division.append(division) + cour_num.append(number_class) + cour_time__location.append(time_location) + + print(f"{number_class} 완료") +for key, value in major00_700_800.items(): + for num in range (700, 800): + url = "https://infodepot.korea.ac.kr/lecture1/lecsubjectPlanViewNew.jsp?year=2024&term=2R&grad_cd=0136&col_cd=9999&dept_cd="+ value +"&cour_cd=" + key + str(num).zfill(3) + "&cour_cls=" + "00" + "&" + html = req.urlopen(url) + doc = BeautifulSoup(html,"html.parser") + h3_tag = doc.find('h3') + + if (not h3_tag) or not h3_tag.string or len(h3_tag.string) == 19: + print('no site') + continue + + try: + rows = doc.find(class_="tbl_view").tbody.find_all('tr') + #학점 + credit = rows[0].find_all('td')[1].text.strip() + #이수구분 + division = rows[2].find_all('td')[0].text.strip() + #학수번호-분반 + number_class = rows[1].find_all('td')[0].text.strip() + #강의시간표 및 장소 + time_location = rows[3].find_all('td')[1].text.strip() + #과목명 + title = rows[4].find_all('td')[0].text.strip() + #교수명 + prof = doc.find(class_="bottom_view").find_all('tr')[0].find_all('td')[0].text.strip() + + except Exception as e: + print(f"Error parsing {url}: {e}") + time = None + prof = None + course_credit = None + course_division = None + course_code_sec = None + course_schedule_location = None + + cour_prof.append(prof) + # cour_number = f'GEST{str(num).zfill(3)}-{str(cour_cls).zfill(2)}' + cour_name.append(title) + cour_credit.append(credit) + cour_division.append(division) + cour_num.append(number_class) + cour_time__location.append(time_location) + + print(f"{number_class} 완료") + + + + + +# 데이터프레임으로 변환 및 저장 +df = pd.DataFrame({ + '학수번호-분반': cour_num, + '과목명': cour_name, + '교수명': cour_prof, + '학점': cour_credit, + '이수구분': cour_division, + '강의시간표 및 장소': cour_time__location +}) + +# 데이터프레임을 CSV 파일로 저장 +df.to_csv('전공9.csv', index=False, encoding='utf-8-sig') +print("CSV 파일로 저장 완료") \ No newline at end of file