Spaces:
Paused
Paused
Update app.py
Browse files123456789101112131415161718195 unmodified lines252627202829303132333435363738394041424344454647import 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 lines
for entry in entries: st.subheader(entry.title) st.write(entry.summary) # Display publication date st.write(f"Published on: {entry.published}")
# Check for media content media_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 content content_encoded = entry.get('content_encoded', entry.description) images, text = extract_images_and_text(content_encoded) st.write(text) # Display plain text for img_url in images: st.image(img_url, width=600) # Display images if any
st.write(f"[Read more]({entry.link})")app.py+27-1