Browse Source

Merge pull request #932 from a01200356/duckduckgo

[fix] fix duckduckgo's offset
Adam Tauber 7 years ago
parent
commit
a932381d7a
2 changed files with 4 additions and 4 deletions
  1. 3
    4
      searx/engines/duckduckgo.py
  2. 1
    0
      tests/unit/engines/test_duckduckgo.py

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

79
     if params['time_range'] and params['time_range'] not in time_range_dict:
79
     if params['time_range'] and params['time_range'] not in time_range_dict:
80
         return params
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
     region_code = get_region_code(params['language'])
84
     region_code = get_region_code(params['language'])
86
     if region_code:
85
     if region_code:
87
         params['url'] = url.format(
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
     else:
88
     else:
90
         params['url'] = url.format(
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
     if params['time_range'] in time_range_dict:
92
     if params['time_range'] in time_range_dict:
94
         params['url'] += time_range_url.format(range=time_range_dict[params['time_range']])
93
         params['url'] += time_range_url.format(range=time_range_dict[params['time_range']])

+ 1
- 0
tests/unit/engines/test_duckduckgo.py View File

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