on master help sign in
[fix] fix paging of duckduckgo
commit742e4dfdcc9c1c47e76f0f9c5e9feb8a1c59b664 authorNoémi Ványi <sitbackandwait@gmail.com> dateWed 1 Feb 2017, 20:43 (10 years ago) parent3ecde5b
1 file changed+5−4
searx/engines/duckduckgo.py+5−4
searx/engines/duckduckgo.py+5−4
@@ -27,7 +27,7 @@ supported_languages_url = 'https://duckduckgo.com/d2030.js'
2727time_range_support = True
2828
2929# 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}'
3131time_range_url = '&df={range}'
3232
3333time_range_dict = {'day': 'd',
@@ -46,7 +46,8 @@ def request(query, params):
4646 if params['time_range'] and params['time_range'] not in time_range_dict:
4747 return params
4848
49− offset = (params['pageno'] - 1) * 30
49+ offset = 30 + (params['pageno'] - 1) * 50
50+ dc_param = offset + 1
5051
5152 # custom fixes for languages
5253 if params['language'] == 'all':
@@ -79,10 +80,10 @@ def request(query, params):
7980
8081 if locale:
8182 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)
8384 else:
8485 params['url'] = url.format(
85− query=urlencode({'q': query}), offset=offset)
86+ query=urlencode({'q': query}), offset=offset, dc_param=dc_param)
8687
8788 if params['time_range'] in time_range_dict:
8889 params['url'] += time_range_url.format(range=time_range_dict[params['time_range']])