CSB261 commited on
Commit
6b9e3b8
โ€ข
1 Parent(s): b92961a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -8
app.py CHANGED
@@ -13,17 +13,24 @@ soup = BeautifulSoup(response.content, 'html.parser')
13
  news_list = []
14
 
15
  for news_item in soup.select('div.rankingnews_box ul.rankingnews_list li'):
16
- rank = news_item.find('em', class_='list_ranking_num').text
17
- title = news_item.find('a', class_='list_title').text.strip()
18
- link = news_item.find('a', class_='list_title')['href']
19
- time = news_item.find('span', class_='list_time').text.strip()
 
 
 
 
 
 
 
 
 
 
20
 
21
  # ์ด๋ฏธ์ง€ ํƒœ๊ทธ์™€ src ์†์„ฑ ํ™•์ธ
22
  img_tag = news_item.find('img')
23
- if img_tag and 'src' in img_tag.attrs:
24
- image_url = img_tag['src']
25
- else:
26
- image_url = 'No Image Available'
27
 
28
  news_list.append({
29
  'Rank': rank,
 
13
  news_list = []
14
 
15
  for news_item in soup.select('div.rankingnews_box ul.rankingnews_list li'):
16
+ # ์ˆœ์œ„ ๋ฒˆํ˜ธ๊ฐ€ ์กด์žฌํ•˜๋Š”์ง€ ํ™•์ธ
17
+ rank_tag = news_item.find('em', class_='list_ranking_num')
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,