[enh] paging support for mediawiki

This commit is contained in:
asciimoo 2014-01-30 01:44:12 +01:00
parent 81b4cc77da
commit 35ecb6ec5d
2 changed files with 5 additions and 2 deletions

View File

@ -3,13 +3,15 @@ from urllib import urlencode, quote
url = 'https://en.wikipedia.org/' url = 'https://en.wikipedia.org/'
search_url = url + 'w/api.php?action=query&list=search&{query}&srprop=timestamp&format=json' # noqa search_url = url + 'w/api.php?action=query&list=search&{query}&srprop=timestamp&format=json&sroffset={offset}' # noqa
number_of_results = 10 number_of_results = 10
def request(query, params): def request(query, params):
params['url'] = search_url.format(query=urlencode({'srsearch': query})) offset = (params['pageno'] - 1) * 10
params['url'] = search_url.format(query=urlencode({'srsearch': query}),
offset=offset)
return params return params

View File

@ -10,6 +10,7 @@ engines:
engine : mediawiki engine : mediawiki
url : https://en.wikipedia.org/ url : https://en.wikipedia.org/
number_of_results : 1 number_of_results : 1
paging : False
- name : bing - name : bing
engine : bing engine : bing