Spaces:
Running
Running
import requests | |
import feedparser | |
import gradio as gr | |
# Define the RSS feed URLs | |
news_sources = { | |
"SM+": "https://gitlab.com/privatemedia/smrss/-/blob/master/smprsshypermedia.xml", | |
"Ad โขAssetmartโข on Telegram": "http://bit.ly/4hTmAG", | |
"ABP News": "https://www.abplive.com/home/feed", | |
"Axiom Article ๐ Spin-Up a professional article. Sponsored in part by SM+": "https://t.me/SMPlusSevenCities_Bot/AxiomArticle", | |
"Ad โขShopify ๐ Fash/ Wherehouseโข ๐": "https://fashwherehouse.myshopify.com", | |
"Business Line": "https://www.thehindubusinessline.com/feeder/default.rss", | |
"Fashionista ๐ Elevate ๐ Your Wardrobe Today SS/25 #fab": "https://rn149855.myshopify.com", | |
"Futures Crypto (Trading View) Sponsored in part by SM+ ๐ค": "https://politepol.com/fd/eg8zlQt2YgLU.xml", | |
"Gaby Sprugs ๐ค Nano ๐ ๐ค": "https://gitlab.com/privatemedia/smrss/-/blob/master/smprss.xml?ref_type=heads", | |
"+ - Neutral ๐๐๏ธ Artical Sentiment Analysis sponsored in part by SM+": "https://t.me/SMPlusSevenCities_Bot/plusminusorneutral", | |
"Indian Express": "https://indianexpress.com/section/india/feed", | |
"K-Verse News ๐": "https://politepol.com/fd/H1MU8Bk3wbVU.xml", | |
"Live Mint": "https://www.livemint.com/rss/news", | |
"Money Control": "https://www.moneycontrol.com/rss/latestnews.xml", | |
"NDTV": "https://feeds.feedburner.com/NDTV-LatestNews", | |
"News 18": "https://www.news18.com/commonfeeds/v1/eng/rss/india.xml", | |
"Shipping ๐ข Industry News SMPLUS20 ๐ Econ Indicators- California. Sponsored by SM Plus (SM+)": "https://feedfry.com/rss/11eff3c1ffb32b90aa788bf3027792d8", | |
"Surfing ๐": "https://cdn.mysitemapgenerator.com/shareapi/rss/2303959522", | |
"SM+ Curated Content, Movies and more ๐ ๐ค๐ฟ": "https://smplus.vhx.tv", | |
"The Federal": "https://thefederal.com/feeds.xml", | |
"Tik Tok News ๐ค Feed sponsored by SM+": "https://feedfry.com/rss/11eff2ff9439b661aee1d6bffcf7993f", | |
"#UN #Housing #Celebrity #iheadline #News #CryptoNews #Futures #Spring #2025 #Entertainment #Streaming #GoldCard #Framework #gaming #Pokemon #Tariffs #EggPrices #SpringVibes": "https://feedfry.com/rss/11eff3059298fa75b1de4c8eb41bf065" | |
} | |
# Function to fetch and parse RSS feeds | |
def fetch_news(source): | |
try: | |
feed = feedparser.parse(requests.get(source).content) | |
news_items = [ | |
f"<a href='{entry.link}' target='_blank'>{entry.title}</a>" | |
for entry in feed.entries[:10] # Fetch top 10 headlines | |
] | |
return "<br><br>".join(news_items) if news_items else "No news available." | |
except Exception as e: | |
return f"Error fetching news: {str(e)}" | |
# Gradio interface function | |
def display_news(selected_source): | |
source_url = news_sources[selected_source] | |
headlines = fetch_news(source_url) | |
return headlines | |
# Create Gradio interface | |
def create_interface(): | |
interface = gr.Interface( | |
fn=display_news, | |
inputs=gr.Dropdown(choices=list(news_sources.keys()), label="Select News Source"), | |
outputs=gr.HTML(label="Top Headlines"), | |
title="LIVE News / feeds", | |
description="Select a news source from the dropdown to view its latest headlines with clickable links. SM+ may receive earnings/commissions from affiliate links. iHeadline 1.030 {} Mod is a California Joint Venture Partnership between SM Plus Seven Cities & SM Plus (SM+). SM+ R&D Initiative, Sunsetting search for, AGI driven Intuitive Surfing (dev)" | |
) | |
return interface | |
# Deploy Gradio app | |
if __name__ == "__main__": | |
app = create_interface() | |
app.launch() | |