AIRider commited on
Commit
b3b13e7
ยท
verified ยท
1 Parent(s): 0a6228e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -1
app.py CHANGED
@@ -42,7 +42,12 @@ def scrape_kosdaq_data():
42
  for row in rows:
43
  cols = row.find_all("td")
44
  if cols: # ๋นˆ ํ–‰ ์ œ์™ธ
 
45
  row_data = [col.get_text(strip=True) for col in cols]
 
 
 
 
46
  data.append(row_data)
47
  print(f"๋””๋ฒ„๊น…: ์ถ”์ถœ๋œ ๋ฐ์ดํ„ฐ ํ–‰ ์ˆ˜ - {len(data)}")
48
 
@@ -60,7 +65,10 @@ def scrape_kosdaq_data():
60
  def display_kosdaq_info():
61
  # ๋ฐ์ดํ„ฐ ์Šคํฌ๋ž˜ํ•‘ ๋ฐ ๋ฐ˜ํ™˜
62
  df = scrape_kosdaq_data()
63
- return df
 
 
 
64
 
65
  # Gradio UI ์„ค์ •
66
  gr.Interface(
 
42
  for row in rows:
43
  cols = row.find_all("td")
44
  if cols: # ๋นˆ ํ–‰ ์ œ์™ธ
45
+ # ๊ฐ ์—ด์˜ ํ…์ŠคํŠธ๋ฅผ ์ถ”์ถœ
46
  row_data = [col.get_text(strip=True) for col in cols]
47
+ # ๋งํฌ๊ฐ€ ์žˆ๋Š” ๊ฒฝ์šฐ ์ข…๋ชฉ๋ช…์„ ์ถ”๊ฐ€
48
+ link = row.find("a", class_="tltle")
49
+ if link:
50
+ row_data[1] = link.text.strip()
51
  data.append(row_data)
52
  print(f"๋””๋ฒ„๊น…: ์ถ”์ถœ๋œ ๋ฐ์ดํ„ฐ ํ–‰ ์ˆ˜ - {len(data)}")
53
 
 
65
  def display_kosdaq_info():
66
  # ๋ฐ์ดํ„ฐ ์Šคํฌ๋ž˜ํ•‘ ๋ฐ ๋ฐ˜ํ™˜
67
  df = scrape_kosdaq_data()
68
+ if not df.empty:
69
+ return df
70
+ else:
71
+ return pd.DataFrame({"๊ฒฐ๊ณผ": ["๋ฐ์ดํ„ฐ๋ฅผ ๊ฐ€์ ธ์˜ค๋Š” ๋ฐ ์‹คํŒจํ–ˆ์Šต๋‹ˆ๋‹ค."]})
72
 
73
  # Gradio UI ์„ค์ •
74
  gr.Interface(