mirror of https://github.com/searxng/searxng.git
[enh] bing, google paging support
This commit is contained in:
parent
8bb94e3dc4
commit
ca271fd861
|
@ -3,13 +3,17 @@ from urllib import urlencode
|
||||||
from cgi import escape
|
from cgi import escape
|
||||||
|
|
||||||
base_url = 'http://www.bing.com/'
|
base_url = 'http://www.bing.com/'
|
||||||
search_string = 'search?{query}'
|
search_string = 'search?{query}&first={offset}'
|
||||||
locale = 'en-US' # see http://msdn.microsoft.com/en-us/library/dd251064.aspx
|
locale = 'en-US' # see http://msdn.microsoft.com/en-us/library/dd251064.aspx
|
||||||
|
|
||||||
|
paging = True
|
||||||
|
|
||||||
|
|
||||||
def request(query, params):
|
def request(query, params):
|
||||||
|
offset = (params['pageno'] - 1) * 10 + 1
|
||||||
search_path = search_string.format(
|
search_path = search_string.format(
|
||||||
query=urlencode({'q': query, 'setmkt': locale}))
|
query=urlencode({'q': query, 'setmkt': locale}),
|
||||||
|
offset=offset)
|
||||||
#if params['category'] == 'images':
|
#if params['category'] == 'images':
|
||||||
# params['url'] = base_url + 'images/' + search_path
|
# params['url'] = base_url + 'images/' + search_path
|
||||||
params['url'] = base_url + search_path
|
params['url'] = base_url + search_path
|
||||||
|
|
|
@ -5,12 +5,16 @@ from json import loads
|
||||||
|
|
||||||
categories = ['general']
|
categories = ['general']
|
||||||
|
|
||||||
|
paging = True
|
||||||
|
|
||||||
url = 'https://ajax.googleapis.com/'
|
url = 'https://ajax.googleapis.com/'
|
||||||
search_url = url + 'ajax/services/search/web?v=1.0&start=0&rsz=large&safe=off&filter=off&{query}' # noqa
|
search_url = url + 'ajax/services/search/web?v=1.0&start={offset}&rsz=large&safe=off&filter=off&{query}' # noqa
|
||||||
|
|
||||||
|
|
||||||
def request(query, params):
|
def request(query, params):
|
||||||
params['url'] = search_url.format(query=urlencode({'q': query}))
|
offset = (params['pageno'] - 1) * 8
|
||||||
|
params['url'] = search_url.format(offset=offset,
|
||||||
|
query=urlencode({'q': query}))
|
||||||
return params
|
return params
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue