import requests import feedparser import gradio as gr # Define the RSS feed URLs news_sources = { "SM+": "https://smplus.pages.dev", "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://rss.app/feeds/WWmoL46gc5EjFEyu.xml", "Bitcoin Strategic Reserve News": "https://cdn.mysitemapgenerator.com/shareapi/rss/2502907090", "BRICS Currency News": "http://fetchrss.com/rss/67bca52dda01b8237d0cd46367bcea7171f66470280b2d72.xml", "Ad Shopify πŸ‘œ Fash/ Wherehouseβ„’ πŸ†•": "https://rss.app/feeds/6VggZDhxI8rYAwB6.xml", "Business Line": "https://www.thehindubusinessline.com/feeder/default.rss", "iHeadline Influencers πŸ€“": "https://cdn.mysitemapgenerator.com/shareapi/rss/0703926003", "+ - Neutral πŸ†•πŸ—žοΈ Artical Sentiment Analysis sponsored in part by SM+": "https://rss.app/feeds/YOXkC0HOLQ9IFiUs.xml", "Futures Crypto (Trading View) Sponsored in part by SM+ πŸ€‘": "https://politepol.com/fd/eg8zlQt2YgLU.xml", "Ad ebay πŸ›οΈ Shop deals SS/25": "http://fetchrss.com/rss/67bca52dda01b8237d0cd46367bce3f0b8382c6fdd0fc575.xml", "K-Verse News πŸ†•": "https://politepol.com/fd/H1MU8Bk3wbVU.xml", "Surfing 🌊 News": "http://fetchrss.com/rss/67bca52dda01b8237d0cd46367bce863c789cad48e0a7922.xml", "India Today": "https://www.indiatoday.in/rss/home", "Indian Express": "https://indianexpress.com/section/india/feed", "Live Mint": "https://www.livemint.com/rss/news", "Money Control": "https://www.moneycontrol.com/rss/latestnews.xml", "Manorama - English": "https://www.onmanorama.com/kerala.feeds.onmrss.xml", "Music Investing πŸ†• 🎢 🎡 πŸ€‘ Sponsored in part by DMIM, STRM & WVL on the Bitcoin Cash Blockchain": "https://rss.app/feeds/tMDd5ea5avBWLDG0.xml", "NDTV": "https://feeds.feedburner.com/NDTV-LatestNews", "News 18": "https://www.news18.com/commonfeeds/v1/eng/rss/india.xml", "SM+ Curated Content, Movies and more πŸ†• πŸ€“πŸΏ": "https://rss.app/feeds/diDfJzH6owTFfAcP.xml", "The Federal": "https://thefederal.com/feeds.xml", "The Hindu": "https://www.thehindu.com/feeder/default.rss", "Tik Tok News πŸ€“ Feed sponsored by SM+": "https://feedfry.com/rss/11eff2ff9439b661aee1d6bffcf7993f", "#UN #Housing #Celebrity #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"{entry.title}" for entry in feed.entries[:10] # Fetch top 10 headlines ] return "

".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" ) return interface # Deploy Gradio app if __name__ == "__main__": app = create_interface() app.launch()