Przeglądaj źródła

Merge pull request #932 from a01200356/duckduckgo

[fix] fix duckduckgo's offset
Adam Tauber 7 lat temu
rodzic
commit
a932381d7a

+ 3
- 4
searx/engines/duckduckgo.py Wyświetl plik

@@ -79,16 +79,15 @@ def request(query, params):
79 79
     if params['time_range'] and params['time_range'] not in time_range_dict:
80 80
         return params
81 81
 
82
-    offset = 30 + (params['pageno'] - 1) * 50
83
-    dc_param = offset + 1
82
+    offset = (params['pageno'] - 1) * 30
84 83
 
85 84
     region_code = get_region_code(params['language'])
86 85
     if region_code:
87 86
         params['url'] = url.format(
88
-            query=urlencode({'q': query, 'kl': region_code}), offset=offset, dc_param=dc_param)
87
+            query=urlencode({'q': query, 'kl': region_code}), offset=offset, dc_param=offset)
89 88
     else:
90 89
         params['url'] = url.format(
91
-            query=urlencode({'q': query}), offset=offset, dc_param=dc_param)
90
+            query=urlencode({'q': query}), offset=offset, dc_param=offset)
92 91
 
93 92
     if params['time_range'] in time_range_dict:
94 93
         params['url'] += time_range_url.format(range=time_range_dict[params['time_range']])

+ 1
- 0
tests/unit/engines/test_duckduckgo.py Wyświetl plik

@@ -18,6 +18,7 @@ class TestDuckduckgoEngine(SearxTestCase):
18 18
         self.assertIn(query, params['url'])
19 19
         self.assertIn('duckduckgo.com', params['url'])
20 20
         self.assertIn('ch-de', params['url'])
21
+        self.assertIn('s=0', params['url'])
21 22
 
22 23
         # when ddg uses non standard code
23 24
         dicto['language'] = 'en-GB'