-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathstock_news_page.py
More file actions
23 lines (19 loc) · 841 Bytes
/
Copy pathstock_news_page.py
File metadata and controls
23 lines (19 loc) · 841 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import streamlit as st
import feedparser
def app():
st.title("Stock News RSS Feed")
# Input for selecting stock ticker (e.g., GOOGL, AAPL)
ticker = st.text_input("Enter a ticker symbol (e.g., GOOGL, AAPL, MSFT):", value="GOOGL").upper()
if ticker:
# Fetch the stock news using RSS feed
feed_url = f"https://finance.yahoo.com/rss/headline?s={ticker}"
feed = feedparser.parse(feed_url)
if feed.entries:
st.subheader(f"Recent News for {ticker}:")
for entry in feed.entries:
st.write(f"**Title:** {entry.title}")
st.write(f"**Link:** [Read more]({entry.link})")
st.write(f"**Published:** {entry.published}")
st.write("---")
else:
st.write("No news found for the given ticker symbol.")