on master help sign in
add time range search for google
commit2e5839503f7a147e6759e124a3694d1e6b6631fd authorNoemi Vanyi <sitbackandwait@gmail.com> dateMon 18 Jul 2016, 16:09 (10 years ago) parent713d304
1 file changed+8
searx/engines/google.py+8
searx/engines/google.py+8
@@ -24,6 +24,7 @@ categories = ['general']
2424paging = True
2525language_support = True
2626use_locale_domain = True
27+time_range_support = True
2728
2829# based on https://en.wikipedia.org/wiki/List_of_Google_domains and tests
2930default_hostname = 'www.google.com'
@@ -92,6 +93,11 @@ search_url = ('https://{hostname}' +
9293 search_path +
9394 '?{query}&start={offset}&gws_rd=cr&gbv=1&lr={lang}&ei=x')
9495
96+time_range_search = "&tbs=qdr:{range}"
97+time_range_dict = {'day': 'd',
98+ 'week': 'w',
99+ 'month': 'm'}
100+
95101# other URLs
96102map_hostname_start = 'maps.google.'
97103maps_path = '/maps'
@@ -179,6 +185,8 @@ def request(query, params):
179185 query=urlencode({'q': query}),
180186 hostname=google_hostname,
181187 lang=url_lang)
188+ if params['time_range']:
189+ params['url'] += time_range_search.format(range=time_range_dict[params['time_range']])
182190
183191 params['headers']['Accept-Language'] = language
184192 params['headers']['Accept'] = 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8'