Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -24,7 +24,8 @@ def search_news_headlines(source: str) -> str:
|
|
| 24 |
"""Searches for recent news headlines from specified source using DuckDuckGo.
|
| 25 |
|
| 26 |
Args:
|
| 27 |
-
source: News source from supported list (BBC, CNN,
|
|
|
|
| 28 |
|
| 29 |
Returns:
|
| 30 |
Formatted news results or error message
|
|
@@ -45,8 +46,8 @@ def search_news_headlines(source: str) -> str:
|
|
| 45 |
if not domain:
|
| 46 |
return f"Error: {source} is not a supported news source"
|
| 47 |
|
| 48 |
-
#
|
| 49 |
-
search_query = f"site:{domain}
|
| 50 |
|
| 51 |
# Use existing DuckDuckGoSearchTool implementation
|
| 52 |
ddg_tool = DuckDuckGoSearchTool(max_results=5)
|
|
@@ -56,10 +57,10 @@ def search_news_headlines(source: str) -> str:
|
|
| 56 |
import re
|
| 57 |
headlines = re.findall(r'\[(.*?)\]\((.*?)\)', raw_results)
|
| 58 |
|
| 59 |
-
# Filter out navigation/section pages
|
| 60 |
filtered_headlines = []
|
| 61 |
for title, link in headlines:
|
| 62 |
-
if not any(x in title.lower() for x in ['
|
| 63 |
filtered_headlines.append((title, link))
|
| 64 |
|
| 65 |
# Format the results
|
|
|
|
| 24 |
"""Searches for recent news headlines from specified source using DuckDuckGo.
|
| 25 |
|
| 26 |
Args:
|
| 27 |
+
source: News source from supported list (BBC News, CNN, Reuters, AP,
|
| 28 |
+
Fox News, CBS News, Wall Street Journal, Daily Mail)
|
| 29 |
|
| 30 |
Returns:
|
| 31 |
Formatted news results or error message
|
|
|
|
| 46 |
if not domain:
|
| 47 |
return f"Error: {source} is not a supported news source"
|
| 48 |
|
| 49 |
+
# Simplified search query
|
| 50 |
+
search_query = f"site:{domain} when:7d"
|
| 51 |
|
| 52 |
# Use existing DuckDuckGoSearchTool implementation
|
| 53 |
ddg_tool = DuckDuckGoSearchTool(max_results=5)
|
|
|
|
| 57 |
import re
|
| 58 |
headlines = re.findall(r'\[(.*?)\]\((.*?)\)', raw_results)
|
| 59 |
|
| 60 |
+
# Filter out navigation/section pages but with fewer restrictions
|
| 61 |
filtered_headlines = []
|
| 62 |
for title, link in headlines:
|
| 63 |
+
if not any(x in title.lower() for x in ['video clips', 'contact us', 'about us']):
|
| 64 |
filtered_headlines.append((title, link))
|
| 65 |
|
| 66 |
# Format the results
|