update geos google script
This commit is contained in:
@@ -178,18 +178,23 @@ def fetch_duckduckgo_news_context(trend_title, hours=24):
|
||||
logging.warning(f"DuckDuckGo News context fetch failed for '{trend_title}': {e}")
|
||||
return trend_title
|
||||
|
||||
def curate_from_google_trends():
|
||||
# Fetch Google Trends data
|
||||
trends = fetch_google_trends()
|
||||
if not trends:
|
||||
def curate_from_google_trends(geo_list=['US']):
|
||||
# Fetch Google Trends data for each geo
|
||||
all_trends = []
|
||||
for geo in geo_list:
|
||||
trends = scrape_google_trends(geo=geo)
|
||||
if trends:
|
||||
all_trends.extend(trends)
|
||||
|
||||
if not all_trends:
|
||||
print("No Google Trends data available")
|
||||
logging.info("No Google Trends data available")
|
||||
return None, None, None
|
||||
|
||||
attempts = 0
|
||||
max_attempts = 10
|
||||
while attempts < max_attempts and trends:
|
||||
trend = trends.pop(0)
|
||||
while attempts < max_attempts and all_trends:
|
||||
trend = all_trends.pop(0)
|
||||
title = trend["title"]
|
||||
link = trend.get("link", "https://trends.google.com/")
|
||||
summary = trend.get("summary", "")
|
||||
|
||||
Reference in New Issue
Block a user