forked from a2ran/DSL-23-2-FingerFriend
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path응통_공지.py
126 lines (89 loc) · 4.59 KB
/
응통_공지.py
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
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
import pandas as pd
import tqdm.notebook as tqdm
from bs4 import BeautifulSoup
if __name__ == "__main__":
## 학부 공지
web = '응용통계학과'
sub = "학부"
driver = webdriver.Chrome('chromedriver.exe')
n = 0
data_학부 = []
num = 100_000
while True:
if num < 2:
break
url_학부 = f"https://stat.yonsei.ac.kr/stat/board/under_notice.do?mode=list&&articleLimit=10&article.offset={n}"
driver.get(url_학부)
n += 10
wait = WebDriverWait(driver, 3)
tbody = wait.until(EC.presence_of_element_located((By.CSS_SELECTOR, "#jwxe_main_content > div > div > div > table > tbody")))
rows = tbody.find_elements(By.TAG_NAME, "tr")
for row in rows:
number = row.find_element(By.CSS_SELECTOR, "td:nth-child(1)").text.strip()
if number != "공지":
num = int(number)
title = row.find_element(By.CSS_SELECTOR, "td.text-left > div.c-board-title-wrap").text.strip()
link = row.find_element(By.CSS_SELECTOR, "td.text-left > div.c-board-title-wrap > a").get_attribute("href").strip()
date = row.find_element(By.CSS_SELECTOR, "td:nth-child(5)").text.strip()
data_학부.append([web, sub, num, title, link, date])
driver.quit()
df_학부 = pd.DataFrame(data_학부, columns=["학과", "서브", "id", "제목", "링크", "등록일"])
## 대학원 공지
web = '응용통계학과'
sub = "대학원"
driver = webdriver.Chrome('chromedriver.exe')
n = 0
data_대학원 = []
num = 100_000
while True:
if num < 2:
break
url_대학원 = f"https://stat.yonsei.ac.kr/stat/board/grad_notice.do?mode=list&&articleLimit=10&article.offset={n}"
driver.get(url_대학원)
n += 10
wait = WebDriverWait(driver, 3)
tbody = wait.until(EC.presence_of_element_located((By.CSS_SELECTOR, "#jwxe_main_content > div > div > div > table > tbody")))
rows = tbody.find_elements(By.TAG_NAME, "tr")
for row in rows:
number = row.find_element(By.CSS_SELECTOR, "td:nth-child(1)").text.strip()
if number != "공지":
num = int(number)
title = row.find_element(By.CSS_SELECTOR, "td.text-left > div.c-board-title-wrap").text.strip()
link = row.find_element(By.CSS_SELECTOR, "td.text-left > div.c-board-title-wrap > a").get_attribute("href").strip()
date = row.find_element(By.CSS_SELECTOR, "td:nth-child(5)").text.strip()
data_대학원.append([web, sub, num, title, link, date])
driver.quit()
df_대학원 = pd.DataFrame(data_대학원, columns=["학과", "서브", "id", "제목", "링크", "등록일"])
## 취업 공지
web = '응용통계학과'
sub = "취업"
driver = webdriver.Chrome('chromedriver.exe')
n = 0
data_취업 = []
num = 100_000
while True:
if num < 2:
break
url_취업 = f"https://stat.yonsei.ac.kr/stat/board/job.do?mode=list&&articleLimit=10&article.offset={n}"
driver.get(url_취업)
n += 10
wait = WebDriverWait(driver, 3)
tbody = wait.until(EC.presence_of_element_located((By.CSS_SELECTOR, "#jwxe_main_content > div > div > div > table > tbody")))
rows = tbody.find_elements(By.TAG_NAME, "tr")
for row in rows:
number = row.find_element(By.CSS_SELECTOR, "td:nth-child(1)").text.strip()
if number != "공지":
num = int(number)
title = row.find_element(By.CSS_SELECTOR, "td.text-left > div.c-board-title-wrap").text.strip()
link = row.find_element(By.CSS_SELECTOR, "td.text-left > div.c-board-title-wrap > a").get_attribute("href").strip()
date = row.find_element(By.CSS_SELECTOR, "td:nth-child(5)").text.strip()
data_취업.append([web, sub, num, title, link, date])
driver.quit()
df_취업 = pd.DataFrame(data_취업, columns=["학과", "서브", "id", "제목", "링크", "등록일"])
## concat them all
df_응통 = pd.concat([df_학부, df_대학원, df_취업])
df_응통.to_csv('응통.csv', index = False)