Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -20,26 +20,30 @@ def fetch_kosdaq_data():
|
|
20 |
data = []
|
21 |
for row in rows:
|
22 |
columns = row.find_all("td")
|
23 |
-
if len(columns)
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
|
|
37 |
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
|
|
|
|
|
|
43 |
|
44 |
# DataFrame 생성
|
45 |
columns = ["Rank", "Name", "Current Price", "Difference", "Change Rate",
|
@@ -54,10 +58,10 @@ def fetch_kosdaq_data():
|
|
54 |
|
55 |
def display_data():
|
56 |
df = fetch_kosdaq_data()
|
57 |
-
if df is not None:
|
58 |
return df
|
59 |
else:
|
60 |
-
return "Failed to fetch data. Please check the logs."
|
61 |
|
62 |
# Gradio 인터페이스 설정
|
63 |
def gradio_interface():
|
|
|
20 |
data = []
|
21 |
for row in rows:
|
22 |
columns = row.find_all("td")
|
23 |
+
if len(columns) >= 12: # 12개 열이 있는 행만 처리
|
24 |
+
try:
|
25 |
+
# 데이터 파싱
|
26 |
+
rank = columns[0].get_text(strip=True)
|
27 |
+
name = columns[1].get_text(strip=True)
|
28 |
+
current_price = columns[2].get_text(strip=True)
|
29 |
+
diff = columns[3].get_text(strip=True)
|
30 |
+
change_rate = columns[4].get_text(strip=True)
|
31 |
+
volume = columns[5].get_text(strip=True)
|
32 |
+
buy_price = columns[6].get_text(strip=True)
|
33 |
+
sell_price = columns[7].get_text(strip=True)
|
34 |
+
buy_total = columns[8].get_text(strip=True)
|
35 |
+
sell_total = columns[9].get_text(strip=True)
|
36 |
+
per = columns[10].get_text(strip=True)
|
37 |
+
roe = columns[11].get_text(strip=True)
|
38 |
|
39 |
+
data.append([
|
40 |
+
rank, name, current_price, diff, change_rate,
|
41 |
+
volume, buy_price, sell_price, buy_total,
|
42 |
+
sell_total, per, roe
|
43 |
+
])
|
44 |
+
except Exception as e:
|
45 |
+
print(f"Error parsing row: {e}")
|
46 |
+
continue
|
47 |
|
48 |
# DataFrame 생성
|
49 |
columns = ["Rank", "Name", "Current Price", "Difference", "Change Rate",
|
|
|
58 |
|
59 |
def display_data():
|
60 |
df = fetch_kosdaq_data()
|
61 |
+
if df is not None and not df.empty:
|
62 |
return df
|
63 |
else:
|
64 |
+
return "Failed to fetch data or no data available. Please check the logs."
|
65 |
|
66 |
# Gradio 인터페이스 설정
|
67 |
def gradio_interface():
|