mirror of
https://github.com/searxng/searxng.git
synced 2025-08-03 10:32:21 +02:00
add year filter to engines with time range support && tests
Following engines does not support "Last year": * Bing News * DeviantArt * DuckDuckGo * Yahoo * YouTube (noapi)
This commit is contained in:
parent
c59c76e6ee
commit
b034356825
9 changed files with 43 additions and 2 deletions
|
@ -66,6 +66,9 @@ def _get_url(query, language, offset, time_range):
|
|||
|
||||
# do search-request
|
||||
def request(query, params):
|
||||
if params['time_range'] and params['time_range'] not in time_range_dict:
|
||||
return params
|
||||
|
||||
offset = (params['pageno'] - 1) * 10 + 1
|
||||
|
||||
if params['language'] == 'all':
|
||||
|
|
|
@ -34,6 +34,9 @@ time_range_dict = {'day': 11,
|
|||
|
||||
# do search-request
|
||||
def request(query, params):
|
||||
if params['time_range'] and params['time_range'] not in time_range_dict:
|
||||
return params
|
||||
|
||||
offset = (params['pageno'] - 1) * 24
|
||||
|
||||
params['url'] = search_url.format(offset=offset,
|
||||
|
|
|
@ -41,6 +41,9 @@ content_xpath = './/a[@class="result__snippet"]'
|
|||
|
||||
# do search-request
|
||||
def request(query, params):
|
||||
if params['time_range'] and params['time_range'] not in time_range_dict:
|
||||
return params
|
||||
|
||||
offset = (params['pageno'] - 1) * 30
|
||||
|
||||
if params['language'] == 'all':
|
||||
|
|
|
@ -77,6 +77,9 @@ def _get_language(params):
|
|||
|
||||
# do search-request
|
||||
def request(query, params):
|
||||
if params['time_range'] and params['time_range'] not in time_range_dict:
|
||||
return params
|
||||
|
||||
offset = (params['pageno'] - 1) * 10 + 1
|
||||
language = _get_language(params)
|
||||
|
||||
|
|
|
@ -25,7 +25,8 @@ search_url = base_url + '?search_query={query}&page={page}'
|
|||
time_range_url = '&sp=EgII{time_range}%253D%253D'
|
||||
time_range_dict = {'day': 'Ag',
|
||||
'week': 'Aw',
|
||||
'month': 'BA'}
|
||||
'month': 'BA',
|
||||
'year': 'BQ'}
|
||||
|
||||
embedded_url = '<iframe width="540" height="304" ' +\
|
||||
'data-src="//www.youtube-nocookie.com/embed/{videoid}" ' +\
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue