LinkLinkWu commited on
Commit
0bd503e
·
verified ·
1 Parent(s): ce0fcd0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -30
app.py CHANGED
@@ -1,38 +1,34 @@
1
  import streamlit as st
2
-
3
- st.set_page_config(page_title="Stock News Sentiment Analysis", layout="centered")
4
-
5
  from func import fetch_news, analyze_sentiment, extract_org_entities
6
  import time
7
 
8
- # ---------------- Page Header ----------------
9
- st.markdown(
10
- """
11
- <h1 style="display: flex; align-items: center;">
12
- <img src="https://upload.wikimedia.org/wikipedia/commons/thumb/e/e8/Finance_Icon_Set_2013_-_Analytics.svg/1024px-Finance_Icon_Set_2013_-_Analytics.svg.png"
13
- alt="icon" width="40" style="margin-right: 10px;">
14
- Stock News Sentiment Analysis
15
- </h1>
16
- """,
17
- unsafe_allow_html=True
18
- )
 
19
 
20
- st.markdown(
21
- """
22
- <p style="font-size:17px; margin-top: 0.5rem;">
23
- Analyze the latest news sentiment of companies mentioned in your input.
24
- </p>
25
- <p style="font-size:17px;">
26
- <strong>💡 Try input like:</strong> <em>I want to check Apple, Tesla, and Microsoft.</em>
27
- </p>
28
- <p style="font-size:17px;">
29
- <strong>Note:</strong> News may fail to load if the Finviz website structure changes or access is restricted.
30
- </p>
31
- """,
32
- unsafe_allow_html=True
33
- )
34
 
35
- # ---------------- Input Area ----------------
36
  free_text = st.text_area("Enter text mentioning companies:", height=100)
37
  tickers = extract_org_entities(free_text)
38
 
@@ -41,7 +37,7 @@ if tickers:
41
  else:
42
  tickers = []
43
 
44
- # ---------------- Analysis Trigger ----------------
45
  if st.button("Get News and Sentiment"):
46
  if not tickers:
47
  st.warning("Please mention at least one recognizable company.")
 
1
  import streamlit as st
 
 
 
2
  from func import fetch_news, analyze_sentiment, extract_org_entities
3
  import time
4
 
5
+ # 必须放在最前
6
+ st.set_page_config(page_title="Stock News Sentiment Analysis", layout="centered")
7
+
8
+ # ----------- Header Section with Logo and Title (Safe for all environments) -----------
9
+ col1, col2 = st.columns([1, 10])
10
+ with col1:
11
+ st.image(
12
+ "https://upload.wikimedia.org/wikipedia/commons/thumb/e/e8/Finance_Icon_Set_2013_-_Analytics.svg/1024px-Finance_Icon_Set_2013_-_Analytics.svg.png",
13
+ width=48
14
+ )
15
+ with col2:
16
+ st.markdown("<h1 style='margin-bottom: 0;'>Stock News Sentiment Analysis</h1>", unsafe_allow_html=True)
17
 
18
+ # ----------- Description Below Title -----------
19
+ st.markdown("""
20
+ <p style='font-size:17px; margin-top: 0.5rem;'>
21
+ Analyze the latest news sentiment of companies mentioned in your input.
22
+ </p>
23
+ <p style='font-size:17px;'>
24
+ <strong>💡 Try input like:</strong> <em>I want to check Apple, Tesla, and Microsoft.</em>
25
+ </p>
26
+ <p style='font-size:17px;'>
27
+ <strong>Note:</strong> News may fail to load if the Finviz website structure changes or access is restricted.
28
+ </p>
29
+ """, unsafe_allow_html=True)
 
 
30
 
31
+ # ----------- User Input -----------
32
  free_text = st.text_area("Enter text mentioning companies:", height=100)
33
  tickers = extract_org_entities(free_text)
34
 
 
37
  else:
38
  tickers = []
39
 
40
+ # ----------- Button Trigger Logic -----------
41
  if st.button("Get News and Sentiment"):
42
  if not tickers:
43
  st.warning("Please mention at least one recognizable company.")