Update app.py
Browse files
app.py
CHANGED
@@ -10,7 +10,7 @@ import json # 用於解析 JSON 文件
|
|
10 |
# Streamlit UI 標題
|
11 |
st.title("Booking.com 多項目數據抓取和視覺化展示")
|
12 |
|
13 |
-
#
|
14 |
urls = [
|
15 |
"https://www.booking.com/hotel/it/appartamento-via-genova-roma.zh-tw.html",
|
16 |
"https://www.booking.com/hotel/it/giulia-39-s-coliseum.zh-tw.html",
|
@@ -104,11 +104,13 @@ if st.button("上傳數據至 Google Sheets") and data:
|
|
104 |
|
105 |
# 數據視覺化
|
106 |
st.header("數據視覺化")
|
107 |
-
if
|
108 |
-
#
|
109 |
-
df['
|
110 |
# 使用 Plotly 繪製條形圖
|
111 |
-
fig = px.bar(df, x='標題', y='
|
|
|
|
|
112 |
fig.update_layout(xaxis_title="酒店標題", yaxis_title="評分", xaxis_tickangle=-45)
|
113 |
st.plotly_chart(fig)
|
114 |
else:
|
|
|
10 |
# Streamlit UI 標題
|
11 |
st.title("Booking.com 多項目數據抓取和視覺化展示")
|
12 |
|
13 |
+
# 合併的 URL 列表
|
14 |
urls = [
|
15 |
"https://www.booking.com/hotel/it/appartamento-via-genova-roma.zh-tw.html",
|
16 |
"https://www.booking.com/hotel/it/giulia-39-s-coliseum.zh-tw.html",
|
|
|
104 |
|
105 |
# 數據視覺化
|
106 |
st.header("數據視覺化")
|
107 |
+
if data:
|
108 |
+
# 提取數字評分
|
109 |
+
df['數字評分'] = df['評分'].str.extract(r'評分:(\d+\.\d+)').astype(float)
|
110 |
# 使用 Plotly 繪製條形圖
|
111 |
+
fig = px.bar(df, x='標題', y='數字評分', title="Booking.com 評分比較",
|
112 |
+
labels={'標題': '酒店標題', '數字評分': '評分'},
|
113 |
+
text='數字評分')
|
114 |
fig.update_layout(xaxis_title="酒店標題", yaxis_title="評分", xaxis_tickangle=-45)
|
115 |
st.plotly_chart(fig)
|
116 |
else:
|