forked from williamliu91/rss
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rss.py
33 lines (27 loc) · 1.09 KB
/
rss.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import streamlit as st
import feedparser
# Function to fetch and parse RSS feed
def fetch_rss_feed(ticker):
# URL format for Yahoo Finance RSS feed
feed_url = f"https://finance.yahoo.com/rss/headline?s={ticker}"
feed = feedparser.parse(feed_url)
return feed
# Streamlit app
def main():
st.title("Stock News RSS Feed")
# User input for ticker symbol
ticker = st.text_input("Enter a ticker symbol (e.g., GOOGL, AAPL, MSFT):", value="GOOGL").upper()
if ticker:
with st.spinner("Fetching news..."):
feed = fetch_rss_feed(ticker)
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.")
if __name__ == "__main__":
main()