Spaces:
Running
Running
Update trend_crawl.py
Browse files- trend_crawl.py +3 -2
trend_crawl.py
CHANGED
@@ -24,7 +24,7 @@ TREND_TOPICS = {
|
|
24 |
19: "Travel and Transportation"
|
25 |
}
|
26 |
|
27 |
-
def process_trends_for_country(country_code, trends_list):
|
28 |
if country_code not in trends_json:
|
29 |
trends_json[country_code] = {"All categories" : {}}
|
30 |
for trend in trends_list:
|
@@ -60,6 +60,7 @@ def process_trends_for_country(country_code, trends_list):
|
|
60 |
"searchQueries": trend.volume,
|
61 |
"articles": articles,
|
62 |
}
|
|
|
63 |
|
64 |
def convert_to_datetime( raw_time):
|
65 |
"""Converts time in seconds to a datetime object with UTC timezone, if it exists."""
|
@@ -71,7 +72,7 @@ def get_trends(countries: list):
|
|
71 |
for country in countries:
|
72 |
trends = tr.trending_now(geo=country)
|
73 |
|
74 |
-
process_trends_for_country(country, trends)
|
75 |
all_categories = trends_json[country]["All categories"]
|
76 |
return trends_json
|
77 |
|
|
|
24 |
19: "Travel and Transportation"
|
25 |
}
|
26 |
|
27 |
+
def process_trends_for_country(country_code, trends_list, trends_json):
|
28 |
if country_code not in trends_json:
|
29 |
trends_json[country_code] = {"All categories" : {}}
|
30 |
for trend in trends_list:
|
|
|
60 |
"searchQueries": trend.volume,
|
61 |
"articles": articles,
|
62 |
}
|
63 |
+
return trends_json
|
64 |
|
65 |
def convert_to_datetime( raw_time):
|
66 |
"""Converts time in seconds to a datetime object with UTC timezone, if it exists."""
|
|
|
72 |
for country in countries:
|
73 |
trends = tr.trending_now(geo=country)
|
74 |
|
75 |
+
trends_json = process_trends_for_country(country, trends, trends_json)
|
76 |
all_categories = trends_json[country]["All categories"]
|
77 |
return trends_json
|
78 |
|