You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
searxng/searx/engines/wikipedia.py

16 lines
488 B
Python

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