seawolf2357 commited on
Commit
5713020
·
verified ·
1 Parent(s): b66c71d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -22
app.py CHANGED
@@ -50,30 +50,19 @@ def search_serphouse(query, country, page, num_result):
50
  def is_recent_news(time_str):
51
  if not time_str:
52
  return False
53
- time_parts = time_str.lower().split()
54
- if len(time_parts) < 2:
55
- return False
56
- try:
57
- value = int(time_parts[0])
58
- unit = time_parts[1]
59
- if unit in ['minute', 'minutes', 'hour', 'hours']:
60
- return True
61
- elif unit in ['day', 'days']:
62
- return value <= 1
63
- else:
64
- # 'ago'가 포함된 경우 (예: '2 hours ago')
65
- if 'ago' in time_str.lower():
66
- if unit in ['minute', 'minutes', 'hour', 'hours']:
67
- return True
68
- elif unit in ['day', 'days']:
69
- return value <= 1
70
- except ValueError:
71
- # 날짜 형식인 경우 (예: 'Sep 22, 2024')
72
  try:
73
- date = datetime.strptime(time_str, '%b %d, %Y')
74
- return (datetime.now() - date).days <= 1
75
  except ValueError:
76
- pass
 
77
  return False
78
 
79
  def format_results(results):
 
50
  def is_recent_news(time_str):
51
  if not time_str:
52
  return False
53
+
54
+ time_str = time_str.lower().strip()
55
+
56
+ if time_str == "1 day ago":
57
+ return True
58
+
59
+ if "hours ago" in time_str:
 
 
 
 
 
 
 
 
 
 
 
 
60
  try:
61
+ hours = int(time_str.split()[0])
62
+ return hours <= 24
63
  except ValueError:
64
+ return False
65
+
66
  return False
67
 
68
  def format_results(results):