mirror of https://github.com/searxng/searxng.git
add time range support for bing images
This commit is contained in:
parent
d2e0cbafb2
commit
5c02b9ef31
|
@ -24,11 +24,16 @@ import re
|
||||||
categories = ['images']
|
categories = ['images']
|
||||||
paging = True
|
paging = True
|
||||||
safesearch = True
|
safesearch = True
|
||||||
|
time_range_support = True
|
||||||
|
|
||||||
# search-url
|
# search-url
|
||||||
base_url = 'https://www.bing.com/'
|
base_url = 'https://www.bing.com/'
|
||||||
search_string = 'images/search?{query}&count=10&first={offset}'
|
search_string = 'images/search?{query}&count=10&first={offset}'
|
||||||
|
time_range_string = '&qft=+filterui:age-lt{interval}'
|
||||||
thumb_url = "https://www.bing.com/th?id={ihk}"
|
thumb_url = "https://www.bing.com/th?id={ihk}"
|
||||||
|
time_range_dict = {'day': '1440',
|
||||||
|
'week': '10080',
|
||||||
|
'month': '43200'}
|
||||||
|
|
||||||
# safesearch definitions
|
# safesearch definitions
|
||||||
safesearch_types = {2: 'STRICT',
|
safesearch_types = {2: 'STRICT',
|
||||||
|
@ -58,6 +63,8 @@ def request(query, params):
|
||||||
'&ADLT=' + safesearch_types.get(params['safesearch'], 'DEMOTE')
|
'&ADLT=' + safesearch_types.get(params['safesearch'], 'DEMOTE')
|
||||||
|
|
||||||
params['url'] = base_url + search_path
|
params['url'] = base_url + search_path
|
||||||
|
if params['time_range'] in time_range_dict:
|
||||||
|
params['url'] += time_range_string.format(interval=time_range_dict[params['time_range']])
|
||||||
|
|
||||||
return params
|
return params
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,7 @@ class TestBingImagesEngine(SearxTestCase):
|
||||||
dicto['pageno'] = 1
|
dicto['pageno'] = 1
|
||||||
dicto['language'] = 'fr_FR'
|
dicto['language'] = 'fr_FR'
|
||||||
dicto['safesearch'] = 1
|
dicto['safesearch'] = 1
|
||||||
|
dicto['time_range'] = ''
|
||||||
params = bing_images.request(query, dicto)
|
params = bing_images.request(query, dicto)
|
||||||
self.assertTrue('url' in params)
|
self.assertTrue('url' in params)
|
||||||
self.assertTrue(query in params['url'])
|
self.assertTrue(query in params['url'])
|
||||||
|
|
Loading…
Reference in New Issue