summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAllen <64094914+allendema@users.noreply.github.com>2024-06-15 16:29:22 +0000
committerBnyro <bnyro@tutanota.com>2024-06-16 16:45:03 +0200
commit13eec44b65d19dedddfd85755ed2adab2a22187c (patch)
treee5e98e84db8b65b3de5f6a490ef3eba7530a326c
parente9f8412a6e4b399a3335da73b3d321104bb0c4fb (diff)
downloadsearxng-13eec44b65d19dedddfd85755ed2adab2a22187c.tar.gz
searxng-13eec44b65d19dedddfd85755ed2adab2a22187c.zip
[fix] \!goi irrelevant results AND display more results
-rw-r--r--searx/engines/google_images.py22
1 files 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"],