diff options
| author | Thomas Pointhuber <thomas.pointhuber@gmx.at> | 2015-02-08 21:53:37 +0100 |
|---|---|---|
| committer | Thomas Pointhuber <thomas.pointhuber@gmx.at> | 2015-02-08 21:53:37 +0100 |
| commit | e7de9674b14c2ff06fac009274742819d6468138 (patch) | |
| tree | 6a0de8ca26494c2cb6b9c5028ec2ad45cd1e20d9 /searx/engines | |
| parent | dd4686a3886458f600427aba0ed7b9666b3644db (diff) | |
[enh] add safesearch functionality
2 = strict
1 = moderate
0 = none
Diffstat (limited to 'searx/engines')
| -rw-r--r-- | searx/engines/bing_images.py | 8 | ||||
| -rw-r--r-- | searx/engines/blekko_images.py | 11 |
2 files changed, 18 insertions, 1 deletions
diff --git a/searx/engines/bing_images.py b/searx/engines/bing_images.py index 9d1c22f5a..4798d9f30 100644 --- a/searx/engines/bing_images.py +++ b/searx/engines/bing_images.py @@ -21,12 +21,17 @@ import re # engine dependent config categories = ['images'] paging = True +safesearch = True # search-url base_url = 'https://www.bing.com/' search_string = 'images/search?{query}&count=10&first={offset}' thumb_url = "http://ts1.mm.bing.net/th?id={ihk}" +# safesearch definitions +safesearch_types = {2: 'STRICT', + 1: 'DEMOTE', + 0: 'OFF'} # do search-request def request(query, params): @@ -43,7 +48,8 @@ def request(query, params): offset=offset) params['cookies']['SRCHHPGUSR'] = \ - 'NEWWND=0&NRSLT=-1&SRCHLANG=' + language.split('-')[0] + 'NEWWND=0&NRSLT=-1&SRCHLANG=' + language.split('-')[0] +\ + '&ADLT=' + safesearch_types.get(params['safesearch'], 'DEMOTE') params['url'] = base_url + search_path diff --git a/searx/engines/blekko_images.py b/searx/engines/blekko_images.py index 2bae9c35e..4fbb9b30f 100644 --- a/searx/engines/blekko_images.py +++ b/searx/engines/blekko_images.py @@ -14,11 +14,16 @@ from urllib import urlencode # engine dependent config categories = ['images'] paging = True +safesearch = True # search-url base_url = 'https://blekko.com' search_url = '/api/images?{query}&c={c}' +# safesearch definitions +safesearch_types = {2: '1', + 1: '', + 0: '0'} # do search-request def request(query, params): @@ -31,6 +36,12 @@ def request(query, params): if params['pageno'] != 1: params['url'] += '&page={pageno}'.format(pageno=(params['pageno']-1)) + # let Blekko know we wan't have profiling + params['cookies']['tag_lesslogging'] = '1' + + # parse safesearch argument + params['cookies']['safesearch'] = safesearch_types.get(params['safesearch'], '') + return params |