Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,47 +1,20 @@
|
|
1 |
-
import
|
2 |
-
from bs4 import BeautifulSoup
|
3 |
import pandas as pd
|
4 |
|
5 |
-
#
|
6 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
|
8 |
-
|
9 |
-
response = requests.get(url)
|
10 |
-
soup = BeautifulSoup(response.content, 'html.parser')
|
11 |
|
12 |
-
# ๋ด์ค
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
rank = rank_tag.text if rank_tag else 'No Rank'
|
19 |
-
|
20 |
-
# ์ ๋ชฉ์ด ์กด์ฌํ๋์ง ํ์ธ
|
21 |
-
title_tag = news_item.find('a', class_='list_title')
|
22 |
-
title = title_tag.text.strip() if title_tag else 'No Title'
|
23 |
-
|
24 |
-
# ๋งํฌ๊ฐ ์กด์ฌํ๋์ง ํ์ธ
|
25 |
-
link = title_tag['href'] if title_tag else '#'
|
26 |
-
|
27 |
-
# ์๊ฐ ์ ๋ณด๊ฐ ์กด์ฌํ๋์ง ํ์ธ
|
28 |
-
time_tag = news_item.find('span', class_='list_time')
|
29 |
-
time = time_tag.text.strip() if time_tag else 'No Time'
|
30 |
-
|
31 |
-
# ์ด๋ฏธ์ง ํ๊ทธ์ src ์์ฑ ํ์ธ
|
32 |
-
img_tag = news_item.find('img')
|
33 |
-
image_url = img_tag['src'] if img_tag and 'src' in img_tag.attrs else 'No Image Available'
|
34 |
-
|
35 |
-
news_list.append({
|
36 |
-
'Rank': rank,
|
37 |
-
'Title': title,
|
38 |
-
'Link': link,
|
39 |
-
'Time': time,
|
40 |
-
'Image URL': image_url
|
41 |
-
})
|
42 |
-
|
43 |
-
# ๋ฐ์ดํฐํ๋ ์์ผ๋ก ๋ณํ
|
44 |
-
df = pd.DataFrame(news_list)
|
45 |
-
|
46 |
-
# ๊ฒฐ๊ณผ ์ถ๋ ฅ
|
47 |
-
print(df)
|
|
|
1 |
+
import streamlit as st
|
|
|
2 |
import pandas as pd
|
3 |
|
4 |
+
# ์์ ๋ฐ์ดํฐํ๋ ์ (์ค์ ๋ฐ์ดํฐ๋ก ๊ต์ฒด)
|
5 |
+
df = pd.DataFrame({
|
6 |
+
'Rank': [1, 2, 3],
|
7 |
+
'Title': ['๋ด์ค ์ ๋ชฉ 1', '๋ด์ค ์ ๋ชฉ 2', '๋ด์ค ์ ๋ชฉ 3'],
|
8 |
+
'Link': ['https://news1.com', 'https://news2.com', 'https://news3.com'],
|
9 |
+
'Time': ['1์๊ฐ ์ ', '2์๊ฐ ์ ', '3์๊ฐ ์ '],
|
10 |
+
'Image URL': ['https://example.com/image1.jpg', 'https://example.com/image2.jpg', 'https://example.com/image3.jpg']
|
11 |
+
})
|
12 |
|
13 |
+
st.title('Naver Ranking News')
|
|
|
|
|
14 |
|
15 |
+
# ๊ฐ๋ณ ๋ด์ค ํญ๋ชฉ์ ์ถ๋ ฅ
|
16 |
+
for index, row in df.iterrows():
|
17 |
+
st.image(row['Image URL'], width=100)
|
18 |
+
st.markdown(f"**[{row['Title']}]({row['Link']})**")
|
19 |
+
st.write(f"Rank: {row['Rank']} | Time: {row['Time']}")
|
20 |
+
st.write("---")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|