Browse Source

[fix] fix paging of duckduckgo

Noémi Ványi 8 years ago
parent
commit
742e4dfdcc
1 changed files with 5 additions and 4 deletions
  1. 5
    4
      searx/engines/duckduckgo.py

+ 5
- 4
searx/engines/duckduckgo.py View File

@@ -27,7 +27,7 @@ supported_languages_url = 'https://duckduckgo.com/d2030.js'
27 27
 time_range_support = True
28 28
 
29 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}'
31 31
 time_range_url = '&df={range}'
32 32
 
33 33
 time_range_dict = {'day': 'd',
@@ -46,7 +46,8 @@ def request(query, params):
46 46
     if params['time_range'] and params['time_range'] not in time_range_dict:
47 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 52
     # custom fixes for languages
52 53
     if params['language'] == 'all':
@@ -79,10 +80,10 @@ def request(query, params):
79 80
 
80 81
     if locale:
81 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 84
     else:
84 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 88
     if params['time_range'] in time_range_dict:
88 89
         params['url'] += time_range_url.format(range=time_range_dict[params['time_range']])