mirror of
https://github.com/searxng/searxng.git
synced 2024-11-26 21:01:01 +00:00
Merge pull request #2559 from dalf/upd-duckduckgo
[fix] duckduckgo engine: "!ddg !g" do not redirect to google
This commit is contained in:
commit
ddab00abf4
3 changed files with 12 additions and 1 deletions
|
@ -169,6 +169,7 @@ headers set HTTP header information
|
|||
data set HTTP data information
|
||||
cookies set HTTP cookies
|
||||
verify bool Performing SSL-Validity check
|
||||
allow_redirects bool Follow redirects
|
||||
max_redirects int maximum redirects, hard limit
|
||||
soft_max_redirects int maximum redirects, soft limit. Record an error but don't stop the engine
|
||||
raise_for_httperror bool True by default: raise an exception if the HTTP code of response is >= 300
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -73,6 +73,10 @@ class OnlineProcessor(EngineProcessor):
|
|||
if max_redirects:
|
||||
request_args['max_redirects'] = max_redirects
|
||||
|
||||
# allow_redirects
|
||||
if 'allow_redirects' in params:
|
||||
request_args['allow_redirects'] = params['allow_redirects']
|
||||
|
||||
# soft_max_redirects
|
||||
soft_max_redirects = params.get('soft_max_redirects', max_redirects or 0)
|
||||
|
||||
|
|
Loading…
Reference in a new issue