Browse Source

add time range search for google images

Noemi Vanyi 8 years ago
parent
commit
e9a78f1434
1 changed files with 7 additions and 1 deletions
  1. 7
    1
      searx/engines/google_images.py

+ 7
- 1
searx/engines/google_images.py View File

@@ -19,13 +19,17 @@ from lxml import html
19 19
 categories = ['images']
20 20
 paging = True
21 21
 safesearch = True
22
+time_range_support = True
22 23
 
23 24
 search_url = 'https://www.google.com/search'\
24 25
     '?{query}'\
25 26
     '&tbm=isch'\
26 27
     '&ijn=1'\
27 28
     '&start={offset}'
28
-
29
+time_range_search = "&tbs=qdr:{range}"
30
+time_range_dict = {'day': 'd',
31
+                   'week': 'w',
32
+                   'month': 'm'}
29 33
 
30 34
 # do search-request
31 35
 def request(query, params):
@@ -34,6 +38,8 @@ def request(query, params):
34 38
     params['url'] = search_url.format(query=urlencode({'q': query}),
35 39
                                       offset=offset,
36 40
                                       safesearch=safesearch)
41
+    if params['time_range']:
42
+        params['url'] += time_range_search.format(range=time_range_dict[params['time_range']])
37 43
 
38 44
     if safesearch and params['safesearch']:
39 45
         params['url'] += '&' + urlencode({'safe': 'active'})