Skip to content

Commit

Permalink
bypass google consent with ucbcb=1
Browse files Browse the repository at this point in the history
  • Loading branch information
unixfox committed Jul 9, 2022
1 parent 641e39b commit 6face21
Show file tree
Hide file tree
Showing 7 changed files with 7 additions and 39 deletions.
1 change: 1 addition & 0 deletions searx/engines/google.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,7 @@ def request(query, params):
'oe': "utf8",
'start': offset,
'filter': '0',
'ucbcb': 1,
**additional_parameters,
}
)
Expand Down
9 changes: 1 addition & 8 deletions searx/engines/google_images.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,14 +133,7 @@ def request(query, params):
+ '/search'
+ "?"
+ urlencode(
{
'q': query,
'tbm': "isch",
**lang_info['params'],
'ie': "utf8",
'oe': "utf8",
'num': 30,
}
{'q': query, 'tbm': "isch", **lang_info['params'], 'ie': "utf8", 'oe': "utf8", 'num': 30, 'ucbcb': 1}
)
)

Expand Down
10 changes: 1 addition & 9 deletions searx/engines/google_news.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
# pylint: disable=invalid-name

import binascii
from datetime import datetime
import re
from urllib.parse import urlencode
from base64 import b64decode
Expand Down Expand Up @@ -99,21 +98,14 @@ def request(query, params):
+ '/search'
+ "?"
+ urlencode(
{
'q': query,
**lang_info['params'],
'ie': "utf8",
'oe': "utf8",
'gl': lang_info['country'],
}
{'q': query, **lang_info['params'], 'ie': "utf8", 'oe': "utf8", 'gl': lang_info['country'], 'ucbcb': 1}
)
+ ('&ceid=%s' % ceid)
) # ceid includes a ':' character which must not be urlencoded
params['url'] = query_url

params['headers'].update(lang_info['headers'])
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

Expand Down
2 changes: 1 addition & 1 deletion searx/engines/google_play_apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
}

categories = ["files", "apps"]
search_url = "https://play.google.com/store/search?{query}&c=apps"
search_url = "https://play.google.com/store/search?{query}&c=apps&ucbcb=1"


def request(query, params):
Expand Down
10 changes: 1 addition & 9 deletions searx/engines/google_scholar.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,15 +85,7 @@ def request(query, params):
+ lang_info['subdomain']
+ '/scholar'
+ "?"
+ urlencode(
{
'q': query,
**lang_info['params'],
'ie': "utf8",
'oe': "utf8",
'start': offset,
}
)
+ urlencode({'q': query, **lang_info['params'], 'ie': "utf8", 'oe': "utf8", 'start': offset, 'ucbcb': 1})
)

query_url += time_range_url(params)
Expand Down
10 changes: 1 addition & 9 deletions searx/engines/google_videos.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,15 +118,7 @@ def request(query, params):
+ lang_info['subdomain']
+ '/search'
+ "?"
+ urlencode(
{
'q': query,
'tbm': "vid",
**lang_info['params'],
'ie': "utf8",
'oe': "utf8",
}
)
+ urlencode({'q': query, 'tbm': "vid", **lang_info['params'], 'ie': "utf8", 'oe': "utf8", 'ucbcb': 1})
)

if params['time_range'] in time_range_dict:
Expand Down
4 changes: 1 addition & 3 deletions searx/engines/youtube_noapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
Youtube (Videos)
"""

from datetime import datetime
from functools import reduce
from json import loads, dumps
from urllib.parse import quote_plus
Expand All @@ -26,7 +25,7 @@

# search-url
base_url = 'https://www.youtube.com/results'
search_url = base_url + '?search_query={query}&page={page}'
search_url = base_url + '?search_query={query}&page={page}&ucbcb=1'
time_range_url = '&sp=EgII{time_range}%253D%253D'
# the key seems to be constant
next_page_url = 'https://www.youtube.com/youtubei/v1/search?key=AIzaSyAO_FJ2SlqU8Q4STEHLGCilw_Y9_11qcW8'
Expand All @@ -52,7 +51,6 @@ def request(query, params):
)
params['headers']['Content-Type'] = 'application/json'

params['headers']['Cookie'] = "CONSENT=YES+cb.%s-17-p0.en+F+941;" % datetime.now().strftime("%Y%m%d")
return params


Expand Down

0 comments on commit 6face21

Please sign in to comment.