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

Fix google news
This commit is contained in:
Alexandre Flament 2021-06-18 14:01:03 +02:00 committed by GitHub
commit eb6832eb95
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 2 deletions

View File

@ -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