소스 검색

[fix] fix paging of duckduckgo

Noémi Ványi 8 년 전
부모
커밋
742e4dfdcc
1개의 변경된 파일5개의 추가작업 그리고 4개의 파일을 삭제
  1. 5
    4
      searx/engines/duckduckgo.py

+ 5
- 4
searx/engines/duckduckgo.py 파일 보기

27
 time_range_support = True
27
 time_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}'
31
 time_range_url = '&df={range}'
31
 time_range_url = '&df={range}'
32
 
32
 
33
 time_range_dict = {'day': 'd',
33
 time_range_dict = {'day': 'd',
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
 
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']])