Skip to content

Commit a36a667

Browse files
committed
#635 공지사항 불러오기 방식 변경으로 인한 RSS 방식 도입
절대경로 -> 상대경로로 변경
1 parent 8655dd2 commit a36a667

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

  • backend/contents/views

backend/contents/views/oj.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,16 @@ def get(self, request):
6464
root = ET.fromstring(response.content)
6565

6666
# 필요한 정보 추출
67+
BASE_URL = "https://swedu.pusan.ac.kr"
6768
items = []
6869
for item in root.findall('.//item')[:5]:
70+
link = item.find('link').text or ''
71+
# RSS가 상대 경로(/bbs/...)로 반환할 경우 base URL을 붙여줌
72+
if link and not link.startswith('http'):
73+
link = BASE_URL + link
6974
item_dict = {
7075
'title': item.find('title').text,
71-
'link': item.find('link').text,
76+
'link': link,
7277
'pubDate': item.find('pubDate').text
7378
}
7479
items.append(item_dict)

0 commit comments

Comments
 (0)