CSB261 commited on
Commit
7761dac
โ€ข
1 Parent(s): c539900

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -4
app.py CHANGED
@@ -3,7 +3,7 @@ from bs4 import BeautifulSoup
3
  import pandas as pd
4
  import streamlit as st
5
  import random
6
- import time
7
 
8
  # ๋„ค์ด๋ฒ„ ๋ชจ๋ฐ”์ผ ๋‰ด์Šค ๋žญํ‚น URL
9
  url = "https://m.news.naver.com/rankingList"
@@ -17,7 +17,7 @@ headers = {
17
  # ๋žœ๋ค ๋”œ๋ ˆ์ด ํ•จ์ˆ˜
18
  def random_delay(min_delay=1, max_delay=3):
19
  delay = random.uniform(min_delay, max_delay)
20
- time.sleep(delay)
21
 
22
  # ์›น ํŽ˜์ด์ง€ ์š”์ฒญ ๋ฐ ํŒŒ์‹ฑ
23
  response = requests.get(url, headers=headers)
@@ -48,7 +48,7 @@ for news_box in soup.select('div.rankingnews_box'):
48
 
49
  # ์‹œ๊ฐ„ ์ถ”์ถœ
50
  time_tag = news_item.find('span', class_='list_time')
51
- time = time_tag.text.strip() if time_tag else 'No Time'
52
 
53
  # ์ด๋ฏธ์ง€ URL ์ถ”์ถœ
54
  img_tag = news_item.find('img')
@@ -60,7 +60,7 @@ for news_box in soup.select('div.rankingnews_box'):
60
  'Rank': rank,
61
  'Title': title,
62
  'Link': link,
63
- 'Time': time,
64
  'Image URL': image_url
65
  })
66
 
 
3
  import pandas as pd
4
  import streamlit as st
5
  import random
6
+ import time # time ๋ชจ๋“ˆ์„ ์ž„ํฌํŠธ
7
 
8
  # ๋„ค์ด๋ฒ„ ๋ชจ๋ฐ”์ผ ๋‰ด์Šค ๋žญํ‚น URL
9
  url = "https://m.news.naver.com/rankingList"
 
17
  # ๋žœ๋ค ๋”œ๋ ˆ์ด ํ•จ์ˆ˜
18
  def random_delay(min_delay=1, max_delay=3):
19
  delay = random.uniform(min_delay, max_delay)
20
+ time.sleep(delay) # time ๋ชจ๋“ˆ์˜ sleep ํ•จ์ˆ˜ ์‚ฌ์šฉ
21
 
22
  # ์›น ํŽ˜์ด์ง€ ์š”์ฒญ ๋ฐ ํŒŒ์‹ฑ
23
  response = requests.get(url, headers=headers)
 
48
 
49
  # ์‹œ๊ฐ„ ์ถ”์ถœ
50
  time_tag = news_item.find('span', class_='list_time')
51
+ time_info = time_tag.text.strip() if time_tag else 'No Time'
52
 
53
  # ์ด๋ฏธ์ง€ URL ์ถ”์ถœ
54
  img_tag = news_item.find('img')
 
60
  'Rank': rank,
61
  'Title': title,
62
  'Link': link,
63
+ 'Time': time_info,
64
  'Image URL': image_url
65
  })
66