Add1E commited on
Commit
122d3b3
·
verified ·
1 Parent(s): d28e0f9

Update trend_crawl.py

Browse files
Files changed (1) hide show
  1. trend_crawl.py +6 -0
trend_crawl.py CHANGED
@@ -26,13 +26,18 @@ TREND_TOPICS = {
26
  }
27
  trends_json = {}
28
  def process_trends_for_country(country_code, trends_list):
 
29
  if country_code not in trends_json:
30
  trends_json[country_code] = {"All categories" : {}}
 
31
  for trend in trends_list:
 
32
  timestamp = convert_to_datetime(trend.started_timestamp[0])
33
  current_time = datetime.now(timezone.utc)
 
34
  if current_time - timestamp > timedelta(days=2):
35
  continue
 
36
  category = None
37
  for topic_id in trend.topics:
38
  if topic_id in TREND_TOPICS:
@@ -44,6 +49,7 @@ def process_trends_for_country(country_code, trends_list):
44
  if category not in trends_json[country_code]:
45
  trends_json[country_code][category] = {}
46
 
 
47
  topic_name = trend.keyword
48
 
49
  try:
 
26
  }
27
  trends_json = {}
28
  def process_trends_for_country(country_code, trends_list):
29
+
30
  if country_code not in trends_json:
31
  trends_json[country_code] = {"All categories" : {}}
32
+
33
  for trend in trends_list:
34
+
35
  timestamp = convert_to_datetime(trend.started_timestamp[0])
36
  current_time = datetime.now(timezone.utc)
37
+ print(current_time - timestamp > timedelta(days=2))
38
  if current_time - timestamp > timedelta(days=2):
39
  continue
40
+
41
  category = None
42
  for topic_id in trend.topics:
43
  if topic_id in TREND_TOPICS:
 
49
  if category not in trends_json[country_code]:
50
  trends_json[country_code][category] = {}
51
 
52
+
53
  topic_name = trend.keyword
54
 
55
  try: