From 13eec44b65d19dedddfd85755ed2adab2a22187c Mon Sep 17 00:00:00 2001 From: Allen <64094914+allendema@users.noreply.github.com> Date: Sat, 15 Jun 2024 16:29:22 +0000 Subject: [PATCH] [fix] \!goi irrelevant results AND display more results --- searx/engines/google_images.py | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/searx/engines/google_images.py b/searx/engines/google_images.py index edd386641..68fcf6122 100644 --- a/searx/engines/google_images.py +++ b/searx/engines/google_images.py @@ -63,16 +63,11 @@ def request(query, params): 'https://' + google_info['subdomain'] + '/search' - + "?" - + urlencode( - { - 'q': query, - 'tbm': "isch", - **google_info['params'], - 'asearch': 'isch', - 'async': '_fmt:json,p:1,ijn:' + str(params['pageno']), - } - ) + + '?' + + urlencode({'q': query, 'tbm': "isch", **google_info['params'], 'asearch': 'isch'}) + # don't urlencode this because wildly different AND bad results + # pagination uses Zero-based numbering + + f'&async=_fmt:json,p:1,ijn:{params["pageno"] - 1}' ) if params['time_range'] in time_range_dict: @@ -80,9 +75,13 @@ def request(query, params): if params['safesearch']: query_url += '&' + urlencode({'safe': filter_mapping[params['safesearch']]}) params['url'] = query_url - params['cookies'] = google_info['cookies'] params['headers'].update(google_info['headers']) + # this ua will allow getting ~50 results instead of 10. #1641 + params['headers']['User-Agent'] = ( + 'NSTN/3.60.474802233.release Dalvik/2.1.0 (Linux; U; Android 12;' f' {google_info.get("country", "US")}) gzip' + ) + return params @@ -96,7 +95,6 @@ def response(resp): json_data = loads(resp.text[json_start:]) for item in json_data["ischj"].get("metadata", []): - result_item = { 'url': item["result"]["referrer_url"], 'title': item["result"]["page_title"],