summaryrefslogtreecommitdiff
path: root/searx/engines/wikipedia.py
blob: fcd917abfd04f247b60f7450a654ad156a316b4b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
from json import loads

def request(query, params):
    params['url'] = 'http://en.wikipedia.org/w/api.php?action=query&list=search&srsearch=%s&srprop=timestamp&format=json' % query

    return params


def response(resp):
    search_results = loads(resp.text)
    results = []
    for res in search_results.get('query', {}).get('search', []):
        results.append({'url': 'https://en.wikipedia.org/wiki/%s' % res['title'].replace(' ', '_'), 'title': res['title']})
    return results