searxngRebrandZaclys/searx/engines/wikipedia.py

16 lines
488 B
Python
Raw Normal View History

2013-10-15 18:51:35 +00:00
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', []):
2013-10-15 20:28:27 +00:00
results.append({'url': 'https://en.wikipedia.org/wiki/%s' % res['title'].replace(' ', '_'), 'title': res['title']})
2013-10-15 18:51:35 +00:00
return results