mirror of https://github.com/searxng/searxng.git
add time range search for google images
This commit is contained in:
parent
f13b9fa36a
commit
e9a78f1434
|
@ -19,13 +19,17 @@ from lxml import html
|
||||||
categories = ['images']
|
categories = ['images']
|
||||||
paging = True
|
paging = True
|
||||||
safesearch = True
|
safesearch = True
|
||||||
|
time_range_support = True
|
||||||
|
|
||||||
search_url = 'https://www.google.com/search'\
|
search_url = 'https://www.google.com/search'\
|
||||||
'?{query}'\
|
'?{query}'\
|
||||||
'&tbm=isch'\
|
'&tbm=isch'\
|
||||||
'&ijn=1'\
|
'&ijn=1'\
|
||||||
'&start={offset}'
|
'&start={offset}'
|
||||||
|
time_range_search = "&tbs=qdr:{range}"
|
||||||
|
time_range_dict = {'day': 'd',
|
||||||
|
'week': 'w',
|
||||||
|
'month': 'm'}
|
||||||
|
|
||||||
# do search-request
|
# do search-request
|
||||||
def request(query, params):
|
def request(query, params):
|
||||||
|
@ -34,6 +38,8 @@ def request(query, params):
|
||||||
params['url'] = search_url.format(query=urlencode({'q': query}),
|
params['url'] = search_url.format(query=urlencode({'q': query}),
|
||||||
offset=offset,
|
offset=offset,
|
||||||
safesearch=safesearch)
|
safesearch=safesearch)
|
||||||
|
if params['time_range']:
|
||||||
|
params['url'] += time_range_search.format(range=time_range_dict[params['time_range']])
|
||||||
|
|
||||||
if safesearch and params['safesearch']:
|
if safesearch and params['safesearch']:
|
||||||
params['url'] += '&' + urlencode({'safe': 'active'})
|
params['url'] += '&' + urlencode({'safe': 'active'})
|
||||||
|
|
Loading…
Reference in New Issue