Update app.py
Browse files
app.py
CHANGED
@@ -14,6 +14,7 @@ from nltk.corpus import stopwords
|
|
14 |
from nltk.tokenize import sent_tokenize, word_tokenize
|
15 |
from nltk.probability import FreqDist
|
16 |
import nltk
|
|
|
17 |
|
18 |
# Download necessary NLTK data
|
19 |
nltk.download('punkt')
|
@@ -156,7 +157,14 @@ def google_search(term, num_results=5, lang="en", timeout=5, safe="active", ssl_
|
|
156 |
|
157 |
def google_news_search(term, num_results=5, lang="en", timeout=5, safe="active", ssl_verify=None):
|
158 |
print(f"Searching Google News for term: {term}")
|
159 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
160 |
start = 0
|
161 |
all_results = []
|
162 |
|
@@ -173,10 +181,10 @@ def google_news_search(term, num_results=5, lang="en", timeout=5, safe="active",
|
|
173 |
url="https://news.google.com/search",
|
174 |
headers=headers,
|
175 |
params={
|
176 |
-
"q":
|
177 |
"hl": lang,
|
178 |
-
"gl": "US",
|
179 |
-
"ceid": "US:en"
|
180 |
},
|
181 |
timeout=timeout,
|
182 |
verify=ssl_verify,
|
|
|
14 |
from nltk.tokenize import sent_tokenize, word_tokenize
|
15 |
from nltk.probability import FreqDist
|
16 |
import nltk
|
17 |
+
from datetime import datetime
|
18 |
|
19 |
# Download necessary NLTK data
|
20 |
nltk.download('punkt')
|
|
|
157 |
|
158 |
def google_news_search(term, num_results=5, lang="en", timeout=5, safe="active", ssl_verify=None):
|
159 |
print(f"Searching Google News for term: {term}")
|
160 |
+
|
161 |
+
# Get the current year
|
162 |
+
current_year = datetime.now().year
|
163 |
+
|
164 |
+
# Add the current year to the search term
|
165 |
+
search_term = f"{term} {current_year}"
|
166 |
+
|
167 |
+
escaped_term = urllib.parse.quote_plus(search_term)
|
168 |
start = 0
|
169 |
all_results = []
|
170 |
|
|
|
181 |
url="https://news.google.com/search",
|
182 |
headers=headers,
|
183 |
params={
|
184 |
+
"q": search_term,
|
185 |
"hl": lang,
|
186 |
+
"gl": "US",
|
187 |
+
"ceid": "US:en"
|
188 |
},
|
189 |
timeout=timeout,
|
190 |
verify=ssl_verify,
|