Browse Source

Merge pull request #156 from return42/fix-google-news

Fix google news
Alexandre Flament 3 years ago
parent
commit
eb6832eb95
1 changed files with 4 additions and 2 deletions
  1. 4 2
      searx/engines/google_news.py

+ 4 - 2
searx/engines/google_news.py

@@ -19,6 +19,7 @@ Definitions`_.  Not all parameters can be appied:
 # pylint: disable=invalid-name, missing-function-docstring
 
 import binascii
+from datetime import datetime
 import re
 from urllib.parse import urlencode
 from base64 import b64decode
@@ -94,8 +95,8 @@ def request(query, params):
     ceid = "%s:%s" % (lang_info['country'], lang_info['language'])
 
     # google news redirects en to en-US
-    if lang_info['hl'] == 'en':
-        lang_info['hl'] = 'en-US'
+    if lang_info['params']['hl'] == 'en':
+        lang_info['params']['hl'] = 'en-US'
 
     # Very special to google-news compared to other google engines, the time
     # range is included in the search term.
@@ -115,6 +116,7 @@ def request(query, params):
     params['headers']['Accept'] = (
         'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8'
         )
+    params['headers']['Cookie'] = "CONSENT=YES+cb.%s-14-p0.en+F+941;" % datetime.now().strftime("%Y%m%d")
 
     return params