mirror of
https://github.com/searxng/searxng
synced 2024-01-01 18:24:07 +00:00
[enh] XPath engine - add ISO 639-1 {lang} replacement to search-URL
BTW: remove obsolte params['query'] and not needed paging condition. Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
This commit is contained in:
parent
2065a324d9
commit
1933577c8e
@ -37,8 +37,15 @@ Search URL of the engine, replacements are:
|
|||||||
``{pageno}``:
|
``{pageno}``:
|
||||||
Page number if engine supports pagging :py:obj:`paging`
|
Page number if engine supports pagging :py:obj:`paging`
|
||||||
|
|
||||||
|
``{lang}``:
|
||||||
|
ISO 639-1 language code (en, de, fr ..)
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
lang_all='en'
|
||||||
|
'''Replacement ``{lang}`` in :py:obj:`search_url` if language ``all`` is
|
||||||
|
selected.
|
||||||
|
'''
|
||||||
|
|
||||||
soft_max_redirects = 0
|
soft_max_redirects = 0
|
||||||
'''Maximum redirects, soft limit. Record an error but don't stop the engine'''
|
'''Maximum redirects, soft limit. Record an error but don't stop the engine'''
|
||||||
|
|
||||||
@ -77,14 +84,15 @@ def request(query, params):
|
|||||||
'''Build request parameters (see :ref:`engine request`).
|
'''Build request parameters (see :ref:`engine request`).
|
||||||
|
|
||||||
'''
|
'''
|
||||||
query = urlencode({'q': query})[2:]
|
lang = lang_all
|
||||||
|
if params['language'] != 'all':
|
||||||
fargs = {'query': query}
|
lang = params['language'][:2]
|
||||||
if paging and search_url.find('{pageno}') >= 0:
|
fargs = {
|
||||||
fargs['pageno'] = (params['pageno'] - 1) * page_size + first_page_num
|
'query': urlencode({'q': query})[2:],
|
||||||
|
'lang': lang,
|
||||||
|
'pageno': (params['pageno'] - 1) * page_size + first_page_num
|
||||||
|
}
|
||||||
params['url'] = search_url.format(**fargs)
|
params['url'] = search_url.format(**fargs)
|
||||||
params['query'] = query
|
|
||||||
params['soft_max_redirects'] = soft_max_redirects
|
params['soft_max_redirects'] = soft_max_redirects
|
||||||
logger.debug("query_url --> %s", params['url'])
|
logger.debug("query_url --> %s", params['url'])
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user