summaryrefslogtreecommitdiff
path: root/searx/engines/google_images.py
diff options
context:
space:
mode:
authorEmilien Devos <contact@emiliendevos.be>2022-07-25 12:53:56 +0200
committerMarkus Heiser <markus.heiser@darmarit.de>2022-07-25 13:27:06 +0200
commit5fb2071cb2248c0f0ada7affb0c47f841ddbf102 (patch)
tree601eb8e7109230929d0a13210cf77a69576dcc9b /searx/engines/google_images.py
parent07aa2bfd98fec41427a77532e6890a7af35c9383 (diff)
downloadsearxng-5fb2071cb2248c0f0ada7affb0c47f841ddbf102.tar.gz
searxng-5fb2071cb2248c0f0ada7affb0c47f841ddbf102.zip
[fix] google & youtube - set EU consent cookie
This change the previous bypass method for Google consent using ``ucbcb=1`` (6face215b8) to accept the consent using ``CONSENT=YES+``. The youtube_noapi and google have a similar API, at least for the consent[1]. Get CONSENT cookie from google reguest:: curl -i "https://www.google.com/search?q=time&tbm=isch" \ -A "Mozilla/5.0 (X11; Linux i686; rv:102.0) Gecko/20100101 Firefox/102.0" \ | grep -i consent ... location: https://consent.google.com/m?continue=https://www.google.com/search?q%3Dtime%26tbm%3Disch&gl=DE&m=0&pc=irp&uxe=eomtm&hl=en-US&src=1 set-cookie: CONSENT=PENDING+936; expires=Wed, 24-Jul-2024 11:26:20 GMT; path=/; domain=.google.com; Secure ... PENDING & YES [2]: Google change the way for consent about YouTube cookies agreement in EU countries. Instead of showing a popup in the website, YouTube redirects the user to a new webpage at consent.youtube.com domain ... Fix for this is to put a cookie CONSENT with YES+ value for every YouTube request [1] https://github.com/iv-org/invidious/pull/2207 [2] https://github.com/TeamNewPipe/NewPipeExtractor/issues/592 Closes: https://github.com/searxng/searxng/issues/1432
Diffstat (limited to 'searx/engines/google_images.py')
-rw-r--r--searx/engines/google_images.py5
1 files changed, 2 insertions, 3 deletions
diff --git a/searx/engines/google_images.py b/searx/engines/google_images.py
index b5c7b5302..a65c0ce37 100644
--- a/searx/engines/google_images.py
+++ b/searx/engines/google_images.py
@@ -132,9 +132,7 @@ def request(query, params):
+ lang_info['subdomain']
+ '/search'
+ "?"
- + urlencode(
- {'q': query, 'tbm': "isch", **lang_info['params'], 'ie': "utf8", 'oe': "utf8", 'num': 30, 'ucbcb': 1}
- )
+ + urlencode({'q': query, 'tbm': "isch", **lang_info['params'], 'ie': "utf8", 'oe': "utf8", 'num': 30})
)
if params['time_range'] in time_range_dict:
@@ -143,6 +141,7 @@ def request(query, params):
query_url += '&' + urlencode({'safe': filter_mapping[params['safesearch']]})
params['url'] = query_url
+ params['cookies']['CONSENT'] = "YES+"
params['headers'].update(lang_info['headers'])
params['headers']['Accept'] = 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8'
return params