Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -2,14 +2,39 @@ import gradio as gr
|
|
| 2 |
import requests
|
| 3 |
import xml.etree.ElementTree as ET
|
| 4 |
|
| 5 |
-
# RSS feed links for various
|
| 6 |
RSS_FEEDS = {
|
|
|
|
| 7 |
"Tamil Nadu": "https://trends.google.com/trending/rss?geo=IN-TN",
|
| 8 |
"Karnataka": "https://trends.google.com/trending/rss?geo=IN-KA",
|
| 9 |
"Andhra Pradesh": "https://trends.google.com/trending/rss?geo=IN-AP",
|
| 10 |
"Telangana": "https://trends.google.com/trending/rss?geo=IN-TG",
|
| 11 |
"Delhi": "https://trends.google.com/trending/rss?geo=IN-DL",
|
| 12 |
-
"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
}
|
| 14 |
|
| 15 |
def fetch_trending(region: str):
|
|
@@ -37,9 +62,9 @@ def fetch_trending(region: str):
|
|
| 37 |
|
| 38 |
# Define Gradio interface
|
| 39 |
dropdown = gr.Dropdown(
|
| 40 |
-
label="Select Region",
|
| 41 |
choices=list(RSS_FEEDS.keys()),
|
| 42 |
-
value="
|
| 43 |
)
|
| 44 |
|
| 45 |
output = gr.Textbox(
|
|
@@ -51,8 +76,8 @@ iface = gr.Interface(
|
|
| 51 |
fn=fetch_trending,
|
| 52 |
inputs=dropdown,
|
| 53 |
outputs=output,
|
| 54 |
-
title="
|
| 55 |
-
description="Select a region to view the trending topics. The data is sourced from Google Trends RSS feeds."
|
| 56 |
)
|
| 57 |
|
| 58 |
# Launch the Gradio app
|
|
|
|
| 2 |
import requests
|
| 3 |
import xml.etree.ElementTree as ET
|
| 4 |
|
| 5 |
+
# RSS feed links for various states and India
|
| 6 |
RSS_FEEDS = {
|
| 7 |
+
"India": "https://trends.google.com/trending/rss?geo=IN",
|
| 8 |
"Tamil Nadu": "https://trends.google.com/trending/rss?geo=IN-TN",
|
| 9 |
"Karnataka": "https://trends.google.com/trending/rss?geo=IN-KA",
|
| 10 |
"Andhra Pradesh": "https://trends.google.com/trending/rss?geo=IN-AP",
|
| 11 |
"Telangana": "https://trends.google.com/trending/rss?geo=IN-TG",
|
| 12 |
"Delhi": "https://trends.google.com/trending/rss?geo=IN-DL",
|
| 13 |
+
"Maharashtra": "https://trends.google.com/trending/rss?geo=IN-MH",
|
| 14 |
+
"West Bengal": "https://trends.google.com/trending/rss?geo=IN-WB",
|
| 15 |
+
"Uttar Pradesh": "https://trends.google.com/trending/rss?geo=IN-UP",
|
| 16 |
+
"Kerala": "https://trends.google.com/trending/rss?geo=IN-KL",
|
| 17 |
+
"Rajasthan": "https://trends.google.com/trending/rss?geo=IN-RJ",
|
| 18 |
+
"Gujarat": "https://trends.google.com/trending/rss?geo=IN-GJ",
|
| 19 |
+
"Punjab": "https://trends.google.com/trending/rss?geo=IN-PB",
|
| 20 |
+
"Haryana": "https://trends.google.com/trending/rss?geo=IN-HR",
|
| 21 |
+
"Bihar": "https://trends.google.com/trending/rss?geo=IN-BR",
|
| 22 |
+
"Madhya Pradesh": "https://trends.google.com/trending/rss?geo=IN-MP",
|
| 23 |
+
"Chhattisgarh": "https://trends.google.com/trending/rss?geo=IN-CT",
|
| 24 |
+
"Odisha": "https://trends.google.com/trending/rss?geo=IN-OR",
|
| 25 |
+
"Assam": "https://trends.google.com/trending/rss?geo=IN-AS",
|
| 26 |
+
"Jharkhand": "https://trends.google.com/trending/rss?geo=IN-JH",
|
| 27 |
+
"Himachal Pradesh": "https://trends.google.com/trending/rss?geo=IN-HP",
|
| 28 |
+
"Uttarakhand": "https://trends.google.com/trending/rss?geo=IN-UT",
|
| 29 |
+
"Goa": "https://trends.google.com/trending/rss?geo=IN-GA",
|
| 30 |
+
"Jammu and Kashmir": "https://trends.google.com/trending/rss?geo=IN-JK",
|
| 31 |
+
"Tripura": "https://trends.google.com/trending/rss?geo=IN-TR",
|
| 32 |
+
"Meghalaya": "https://trends.google.com/trending/rss?geo=IN-ML",
|
| 33 |
+
"Manipur": "https://trends.google.com/trending/rss?geo=IN-MN",
|
| 34 |
+
"Nagaland": "https://trends.google.com/trending/rss?geo=IN-NL",
|
| 35 |
+
"Arunachal Pradesh": "https://trends.google.com/trending/rss?geo=IN-AR",
|
| 36 |
+
"Mizoram": "https://trends.google.com/trending/rss?geo=IN-MZ",
|
| 37 |
+
"Sikkim": "https://trends.google.com/trending/rss?geo=IN-SK"
|
| 38 |
}
|
| 39 |
|
| 40 |
def fetch_trending(region: str):
|
|
|
|
| 62 |
|
| 63 |
# Define Gradio interface
|
| 64 |
dropdown = gr.Dropdown(
|
| 65 |
+
label="Select State/Region",
|
| 66 |
choices=list(RSS_FEEDS.keys()),
|
| 67 |
+
value="India" # Default selection
|
| 68 |
)
|
| 69 |
|
| 70 |
output = gr.Textbox(
|
|
|
|
| 76 |
fn=fetch_trending,
|
| 77 |
inputs=dropdown,
|
| 78 |
outputs=output,
|
| 79 |
+
title="Google Trends - Trending Now",
|
| 80 |
+
description="Select a state/region to view the trending topics. The data is sourced from Google Trends RSS feeds."
|
| 81 |
)
|
| 82 |
|
| 83 |
# Launch the Gradio app
|