-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathnotices.py
More file actions
63 lines (57 loc) · 1.24 KB
/
notices.py
File metadata and controls
63 lines (57 loc) · 1.24 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
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
import requests
from bs4 import BeautifulSoup
url = "http://board.sejong.ac.kr/boardlist.do?bbsConfigFK=335"
res = requests.get(url)
res.raise_for_status()
soup = BeautifulSoup(res.text, "lxml")
notices = soup.find_all("td", attrs={"class" : "subject"})
ans_txt = []
ans_link = []
for notice in notices:
txt = notice.a.get_text()
txt = txt.replace("\t","")
txt = txt.replace("\n","")
link = "http://board.sejong.ac.kr" + notice.a["href"]
ans_txt.append(txt)
ans_link.append(link)
response = {
"version": "2.0",
"template": {
"outputs": [
{
"listCard": {
"header": {
"title": "세종대학교 학사공지입니다."
},
"items": [
{
"title": ans_txt[0],
"link": {
"web": ans_link[0]
}
},
{
"title": ans_txt[1],
"link": {
"web": ans_link[1]
}
},
{
"title": ans_txt[2],
"link": {
"web": ans_link[2]
}
}
],
"buttons": [
{
"label": "더보기",
"action": "webLink",
"webLinkUrl": "http://board.sejong.ac.kr/boardlist.do?bbsConfigFK=335"
}
]
}
}
]
}
}