Spaces:
Running
Running
Update trend_crawl.py
Browse files- trend_crawl.py +4 -1
trend_crawl.py
CHANGED
@@ -1,7 +1,6 @@
|
|
1 |
from trendspy import Trends
|
2 |
import streamlit as st
|
3 |
from datetime import datetime, timezone, timedelta
|
4 |
-
tr = Trends()
|
5 |
|
6 |
TREND_TOPICS = {
|
7 |
1: "Autos and Vehicles",
|
@@ -25,6 +24,9 @@ TREND_TOPICS = {
|
|
25 |
19: "Travel and Transportation"
|
26 |
}
|
27 |
trends_json = {}
|
|
|
|
|
|
|
28 |
def process_trends_for_country(country_code, trends_list):
|
29 |
|
30 |
if country_code not in trends_json:
|
@@ -77,6 +79,7 @@ def convert_to_datetime( raw_time):
|
|
77 |
|
78 |
def get_trends(countries: list):
|
79 |
for country in countries:
|
|
|
80 |
trends = tr.trending_now(geo=country)
|
81 |
|
82 |
process_trends_for_country(country, trends)
|
|
|
1 |
from trendspy import Trends
|
2 |
import streamlit as st
|
3 |
from datetime import datetime, timezone, timedelta
|
|
|
4 |
|
5 |
TREND_TOPICS = {
|
6 |
1: "Autos and Vehicles",
|
|
|
24 |
19: "Travel and Transportation"
|
25 |
}
|
26 |
trends_json = {}
|
27 |
+
|
28 |
+
def get_trends_base():
|
29 |
+
return Trends()
|
30 |
def process_trends_for_country(country_code, trends_list):
|
31 |
|
32 |
if country_code not in trends_json:
|
|
|
79 |
|
80 |
def get_trends(countries: list):
|
81 |
for country in countries:
|
82 |
+
tr = get_trends_base()
|
83 |
trends = tr.trending_now(geo=country)
|
84 |
|
85 |
process_trends_for_country(country, trends)
|