talexm commited on
Commit
8879cb8
·
1 Parent(s): 7da4f80
Files changed (1) hide show
  1. app.py +7 -12
app.py CHANGED
@@ -94,37 +94,32 @@ if st.button("Search News About Me"):
94
 
95
  # Google Search: Global News Categories
96
 
97
- # Categories to Fetch News
 
98
  categories = ["Technology", "Sports", "Politics", "Entertainment", "Science"]
99
 
100
- # Title and Introduction
101
  st.title("Global News Insights")
102
 
103
  # News Results Dictionary
104
  news_results = {}
105
 
106
- # Fetch and Display News
107
- st.markdown("### Fetching News for Popular Categories")
108
-
109
  try:
110
- # Fetch Top 3 Articles for Each Category
111
  for category in categories:
112
  try:
113
  news_results[category] = list(search(f"latest {category} news", num_results=3))
114
  except Exception as e:
115
  news_results[category] = [f"Error fetching news: {str(e)}"]
116
 
117
- # Carousel Style Display
118
- st.subheader("Global News Carousel")
119
  for category, articles in news_results.items():
120
- st.markdown(f"#### {category} News")
121
  if articles and "Error fetching news" not in articles[0]:
122
- # Use Embedded Links
123
  for idx, article in enumerate(articles, start=1):
124
- st.markdown(f"{idx}. [Read Article Here]({article})")
125
  else:
126
  st.warning(f"Could not fetch news for **{category}**.")
127
-
128
  except Exception as e:
129
  st.error(f"An unexpected error occurred: {str(e)}")
130
 
 
94
 
95
  # Google Search: Global News Categories
96
 
97
+
98
+ # Categories for News
99
  categories = ["Technology", "Sports", "Politics", "Entertainment", "Science"]
100
 
 
101
  st.title("Global News Insights")
102
 
103
  # News Results Dictionary
104
  news_results = {}
105
 
 
 
 
106
  try:
107
+ # Fetch News for Each Category
108
  for category in categories:
109
  try:
110
  news_results[category] = list(search(f"latest {category} news", num_results=3))
111
  except Exception as e:
112
  news_results[category] = [f"Error fetching news: {str(e)}"]
113
 
114
+ # Display Results
 
115
  for category, articles in news_results.items():
116
+ st.subheader(f"{category} News")
117
  if articles and "Error fetching news" not in articles[0]:
118
+ # Show Actual URLs
119
  for idx, article in enumerate(articles, start=1):
120
+ st.markdown(f"{idx}. [**{article}**]({article})") # Display URL as clickable link
121
  else:
122
  st.warning(f"Could not fetch news for **{category}**.")
 
123
  except Exception as e:
124
  st.error(f"An unexpected error occurred: {str(e)}")
125