[fix] duckduckgo engine: "!ddg !g" do not redirect to google

* searx understand "!ddg !g time" as : send "!g time" to DDG
* !g a DDG bang for Google: DDG return a HTTP redirect to Google

This commit adds a the allows_redirect param not to follow HTTP redirect.

The DDG engine returns a empty result as before without HTTP redirect.
This commit is contained in:
Alexandre Flament 2021-02-09 12:07:19 +01:00
parent d76660463b
commit c22d4c764c
3 changed files with 12 additions and 1 deletions

View file

@ -75,12 +75,18 @@ def request(query, params):
params['data']['kl'] = region_code
params['cookies']['kl'] = region_code
params['data']['df'] = time_range_dict.get(params['time_range'], '')
if params['time_range'] in time_range_dict:
params['data']['df'] = time_range_dict[params['time_range']]
params['allow_redirects'] = False
return params
# get response from search-request
def response(resp):
if resp.status_code == 303:
return []
# ping
headers_ping = dict_subset(resp.request.headers, ['User-Agent', 'Accept-Encoding', 'Accept', 'Cookie'])
get(url_ping, headers=headers_ping)