ソースを参照

[enh] wikipedia search added

asciimoo 11 年 前
コミット
e4b768b6cc
共有1 個のファイルを変更した15 個の追加0 個の削除を含む
  1. 15
    0
      searx/engines/wikipedia.py

+ 15
- 0
searx/engines/wikipedia.py ファイルの表示

1
+from json import loads
2
+
3
+def request(query, params):
4
+    params['url'] = 'http://en.wikipedia.org/w/api.php?action=query&list=search&srsearch=%s&srprop=timestamp&format=json' % query
5
+
6
+    return params
7
+
8
+
9
+def response(resp):
10
+    search_results = loads(resp.text)
11
+    results = []
12
+    for res in search_results.get('query', {}).get('search', []):
13
+        results.append({'url': 'https://en.wikipedia.org/wiki/%s' % res['title'], 'title': res['title']})
14
+    return results
15
+