Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -3,12 +3,10 @@ import requests
|
|
3 |
import xml.etree.ElementTree as ET
|
4 |
import time
|
5 |
|
6 |
-
|
7 |
-
|
8 |
-
def get_news_from_rss():
|
9 |
-
"""์ฐํฉ๋ด์คTV RSS ํผ๋์์ ํค๋๋ผ์ธ ๋ด์ค๋ฅผ ๊ฐ์ ธ์ต๋๋ค."""
|
10 |
try:
|
11 |
-
response = requests.get(
|
12 |
if response.status_code == 200:
|
13 |
root = ET.fromstring(response.content)
|
14 |
items = root.findall(".//item")
|
@@ -22,10 +20,8 @@ def get_news_from_rss():
|
|
22 |
print(f"Error fetching RSS feed: {e}")
|
23 |
return []
|
24 |
|
25 |
-
def display_news():
|
26 |
-
"""
|
27 |
-
news_items = get_news_from_rss()
|
28 |
-
|
29 |
if not news_items:
|
30 |
st.warning("๋ด์ค๋ฅผ ๊ฐ์ ธ์ค๋๋ฐ ์คํจํ์ต๋๋ค.")
|
31 |
return
|
@@ -74,7 +70,18 @@ def main():
|
|
74 |
</style>
|
75 |
""", unsafe_allow_html=True)
|
76 |
|
77 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
78 |
|
79 |
# ์๋ก๊ณ ์นจ ํ์ด๋จธ ์ค์
|
80 |
if 'last_run' not in st.session_state:
|
|
|
3 |
import xml.etree.ElementTree as ET
|
4 |
import time
|
5 |
|
6 |
+
def get_news_from_rss(rss_url):
|
7 |
+
"""RSS ํผ๋์์ ๋ด์ค๋ฅผ ๊ฐ์ ธ์ต๋๋ค."""
|
|
|
|
|
8 |
try:
|
9 |
+
response = requests.get(rss_url)
|
10 |
if response.status_code == 200:
|
11 |
root = ET.fromstring(response.content)
|
12 |
items = root.findall(".//item")
|
|
|
20 |
print(f"Error fetching RSS feed: {e}")
|
21 |
return []
|
22 |
|
23 |
+
def display_news(news_items):
|
24 |
+
"""๋ด์ค๋ฅผ ์์ฝ ๋ฐ ํ์ํฉ๋๋ค."""
|
|
|
|
|
25 |
if not news_items:
|
26 |
st.warning("๋ด์ค๋ฅผ ๊ฐ์ ธ์ค๋๋ฐ ์คํจํ์ต๋๋ค.")
|
27 |
return
|
|
|
70 |
</style>
|
71 |
""", unsafe_allow_html=True)
|
72 |
|
73 |
+
# ๋ด์ค ์ ํ ๋ฒํผ ์ถ๊ฐ
|
74 |
+
news_source = st.sidebar.radio("๋ด์ค ์ ํ", ["jtbc ๋ด์ค", "์ฐํฉ๋ด์ค", "SBS ๋ด์ค"])
|
75 |
+
|
76 |
+
if news_source == "jtbc ๋ด์ค":
|
77 |
+
rss_url = "https://news-ex.jtbc.co.kr/v1/get/rss/issue"
|
78 |
+
elif news_source == "์ฐํฉ๋ด์ค":
|
79 |
+
rss_url = "http://www.yonhapnewstv.co.kr/category/news/headline/feed/"
|
80 |
+
else:
|
81 |
+
rss_url = "https://news.sbs.co.kr/news/headlineRssFeed.do?plink=RSSREADER"
|
82 |
+
|
83 |
+
news_items = get_news_from_rss(rss_url)
|
84 |
+
display_news(news_items)
|
85 |
|
86 |
# ์๋ก๊ณ ์นจ ํ์ด๋จธ ์ค์
|
87 |
if 'last_run' not in st.session_state:
|