Spaces:
Paused
Paused
Update app.py
Browse files12345678910115 unmodified lines1718192021import streamlit as stimport feedparser# Function to fetch and parse RSS feeddef fetch_rss_feed(url):feed = feedparser.parse(url)return feed.entries# RSS feed URLrss_url = "https://feeds.feedburner.com/ndtvnews-top-stories"5 unmodified linesfor entry in entries:st.subheader(entry.title)st.write(entry.summary)st.write(f"[Read more]({entry.link})")123456789101112131415161718195 unmodified lines2526272829303132333435363738394041424344454647import streamlit as stimport feedparserfrom bs4 import BeautifulSoup# Function to fetch and parse RSS feeddef fetch_rss_feed(url):feed = feedparser.parse(url)return feed.entries# Function to extract images and text from HTML contentdef extract_images_and_text(html_content):soup = BeautifulSoup(html_content, 'html.parser')images = [img['src'] for img in soup.find_all('img')]text = soup.get_text()return images, text# RSS feed URLrss_url = "https://feeds.feedburner.com/ndtvnews-top-stories"5 unmodified linesfor entry in entries:st.subheader(entry.title)# Display publication datest.write(f"Published on: {entry.published}")# Check for media contentmedia_content = entry.get('media_content', [])if media_content:for media in media_content:if media.get('url'):st.image(media['url'], width=600) # Display image# Use BeautifulSoup to parse HTML contentcontent_encoded = entry.get('content_encoded', entry.description)images, text = extract_images_and_text(content_encoded)st.write(text) # Display plain textfor img_url in images:st.image(img_url, width=600) # Display images if anyst.write(f"[Read more]({entry.link})")
app.py+27-1