talexm commited on
Commit
521c02b
1 Parent(s): f4ff78b
Files changed (1) hide show
  1. app.py +14 -5
app.py CHANGED
@@ -93,8 +93,6 @@ if st.button("Search News About Me"):
93
  st.warning("Please enter your name or handle to search.")
94
 
95
  # Google Search: Global News Categories
96
-
97
-
98
  # Categories for News
99
  categories = ["Technology", "Sports", "Politics", "Entertainment", "Science"]
100
 
@@ -111,15 +109,26 @@ try:
111
  except Exception as e:
112
  news_results[category] = [f"Error fetching news: {str(e)}"]
113
 
114
- # Display Results Using Columns
115
  for category, articles in news_results.items():
116
  st.subheader(f"{category} News")
117
- cols = st.columns(3) # Create 3 columns for carousel-like layout
118
 
119
  if articles and "Error fetching news" not in articles[0]:
120
  for idx, article in enumerate(articles):
121
  with cols[idx % 3]: # Cycle through columns
122
- st.markdown(f"### [{category} Article {idx + 1}]({article})", unsafe_allow_html=True)
 
 
 
 
 
 
 
 
 
 
 
123
  else:
124
  st.warning(f"Could not fetch news for **{category}**.")
125
  except Exception as e:
 
93
  st.warning("Please enter your name or handle to search.")
94
 
95
  # Google Search: Global News Categories
 
 
96
  # Categories for News
97
  categories = ["Technology", "Sports", "Politics", "Entertainment", "Science"]
98
 
 
109
  except Exception as e:
110
  news_results[category] = [f"Error fetching news: {str(e)}"]
111
 
112
+ # Display Results with Styled Buttons
113
  for category, articles in news_results.items():
114
  st.subheader(f"{category} News")
115
+ cols = st.columns(3) # Create 3 columns for the layout
116
 
117
  if articles and "Error fetching news" not in articles[0]:
118
  for idx, article in enumerate(articles):
119
  with cols[idx % 3]: # Cycle through columns
120
+ st.markdown(
121
+ f"""
122
+ <div style="padding: 10px; border: 1px solid #ccc; border-radius: 5px; margin: 10px; text-align: center;">
123
+ <a href="{article}" target="_blank" style="text-decoration: none;">
124
+ <button style="background-color: #4CAF50; color: white; border: none; padding: 10px 20px; text-align: center; display: inline-block; font-size: 16px; border-radius: 5px;">
125
+ {category} Article {idx + 1}
126
+ </button>
127
+ </a>
128
+ </div>
129
+ """,
130
+ unsafe_allow_html=True,
131
+ )
132
  else:
133
  st.warning(f"Could not fetch news for **{category}**.")
134
  except Exception as e: