Skip to content

Commit

Permalink
[fix] \!goi irrelevant results AND display more results
Browse files Browse the repository at this point in the history
  • Loading branch information
allendema authored and Bnyro committed Jun 16, 2024
1 parent e9f8412 commit 13eec44
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions searx/engines/google_images.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,26 +63,25 @@ 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:
query_url += '&' + urlencode({'tbs': 'qdr:' + time_range_dict[params['time_range']]})
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


Expand All @@ -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"],
Expand Down

0 comments on commit 13eec44

Please sign in to comment.