瀏覽代碼

add time range search for duckduckgo

Noemi Vanyi 8 年之前
父節點
當前提交
f13b9fa36a
共有 1 個檔案被更改,包括 9 行新增0 行删除
  1. 9
    0
      searx/engines/duckduckgo.py

+ 9
- 0
searx/engines/duckduckgo.py 查看文件

22
 categories = ['general']
22
 categories = ['general']
23
 paging = True
23
 paging = True
24
 language_support = True
24
 language_support = True
25
+time_range_support = True
25
 
26
 
26
 # search-url
27
 # search-url
27
 url = 'https://duckduckgo.com/html?{query}&s={offset}'
28
 url = 'https://duckduckgo.com/html?{query}&s={offset}'
29
+time_range_url = '&df={range}'
30
+
31
+time_range_dict = {'day': 'd',
32
+                   'week': 'w',
33
+                   'month': 'm'}
28
 
34
 
29
 # specific xpath variables
35
 # specific xpath variables
30
 result_xpath = '//div[@class="result results_links results_links_deep web-result "]'  # noqa
36
 result_xpath = '//div[@class="result results_links results_links_deep web-result "]'  # noqa
61
         params['url'] = url.format(
67
         params['url'] = url.format(
62
             query=urlencode({'q': query}), offset=offset)
68
             query=urlencode({'q': query}), offset=offset)
63
 
69
 
70
+    if params['time_range']:
71
+        params['url'] += time_range_url.format(range=time_range_dict[params['time_range']])
72
+
64
     return params
73
     return params
65
 
74
 
66
 
75