on master help sign in
[fix] fix paging of duckduckgo
742e4dfNoémi Ványi
searx/engines/duckduckgo.py+5−4
@@ -27,7 +27,7 @@ supported_languages_url = 'https://duckduckgo.com/d2030.js'
27time_range_support = True
27time_range_support = True
28
28
29# search-url
29# search-url
30−url = 'https://duckduckgo.com/html?{query}&s={offset}'
30+url = 'https://duckduckgo.com/html?{query}&s={offset}&api=/d.js&o=json&dc={dc_param}'
31time_range_url = '&df={range}'
31time_range_url = '&df={range}'
32
32
33time_range_dict = {'day': 'd',
33time_range_dict = {'day': 'd',
@@ -46,7 +46,8 @@ def request(query, params):
46 if params['time_range'] and params['time_range'] not in time_range_dict:
46 if params['time_range'] and params['time_range'] not in time_range_dict:
47 return params
47 return params
48
48
49− offset = (params['pageno'] - 1) * 30
49+ offset = 30 + (params['pageno'] - 1) * 50
50+ dc_param = offset + 1
50
51
51 # custom fixes for languages
52 # custom fixes for languages
52 if params['language'] == 'all':
53 if params['language'] == 'all':
@@ -79,10 +80,10 @@ def request(query, params):
79
80
80 if locale:
81 if locale:
81 params['url'] = url.format(
82 params['url'] = url.format(
82− query=urlencode({'q': query, 'kl': locale}), offset=offset)
83+ query=urlencode({'q': query, 'kl': locale}), offset=offset, dc_param=dc_param)
83 else:
84 else:
84 params['url'] = url.format(
85 params['url'] = url.format(
85− query=urlencode({'q': query}), offset=offset)
86+ query=urlencode({'q': query}), offset=offset, dc_param=dc_param)
86
87
87 if params['time_range'] in time_range_dict:
88 if params['time_range'] in time_range_dict:
88 params['url'] += time_range_url.format(range=time_range_dict[params['time_range']])
89 params['url'] += time_range_url.format(range=time_range_dict[params['time_range']])