|
@@ -20,29 +20,33 @@ base_url = None
|
20
|
20
|
search_dir = ''
|
21
|
21
|
dl_prefix = None
|
22
|
22
|
|
|
23
|
+
|
23
|
24
|
def get_time_range(time_range):
|
24
|
25
|
sw = {
|
25
|
|
- 'day' : 1,
|
26
|
|
- 'week': 7,
|
27
|
|
- 'month': 30,
|
28
|
|
- 'year': 365
|
|
26
|
+ 'day': 1,
|
|
27
|
+ 'week': 7,
|
|
28
|
+ 'month': 30,
|
|
29
|
+ 'year': 365
|
29
|
30
|
}
|
30
|
31
|
|
31
|
|
- offset = sw.get(time_range,0)
|
|
32
|
+ offset = sw.get(time_range, 0)
|
32
|
33
|
if not offset:
|
33
|
|
- return ''
|
|
34
|
+ return ''
|
34
|
35
|
|
35
|
36
|
return (date.today()-timedelta(days=offset)).isoformat()
|
36
|
37
|
|
|
38
|
+
|
37
|
39
|
# do search-request
|
38
|
40
|
def request(query, params):
|
39
|
41
|
search_after = get_time_range(params['time_range'])
|
40
|
42
|
search_url = base_url + 'json?query={query}&page={page}&after={after}&dir={dir}&highlight=0'
|
41
|
43
|
|
42
|
|
- params['url'] = search_url.format(query=urlencode({'q': query}), page=params['pageno'], after=search_after, dir=search_dir)
|
|
44
|
+ params['url'] = search_url.format(query=urlencode({'q': query}), page=params['pageno'],
|
|
45
|
+ after=search_after, dir=search_dir)
|
43
|
46
|
|
44
|
47
|
return params
|
45
|
48
|
|
|
49
|
+
|
46
|
50
|
# get response from search-request
|
47
|
51
|
def response(resp):
|
48
|
52
|
results = []
|