summaryrefslogtreecommitdiff
path: root/searx/engines/bing_images.py
diff options
context:
space:
mode:
authorThomas Pointhuber <thomas.pointhuber@gmx.at>2015-02-08 21:53:37 +0100
committerThomas Pointhuber <thomas.pointhuber@gmx.at>2015-02-08 21:53:37 +0100
commite7de9674b14c2ff06fac009274742819d6468138 (patch)
tree6a0de8ca26494c2cb6b9c5028ec2ad45cd1e20d9 /searx/engines/bing_images.py
parentdd4686a3886458f600427aba0ed7b9666b3644db (diff)
downloadsearxng-e7de9674b14c2ff06fac009274742819d6468138.tar.gz
searxng-e7de9674b14c2ff06fac009274742819d6468138.zip
[enh] add safesearch functionality
2 = strict 1 = moderate 0 = none
Diffstat (limited to 'searx/engines/bing_images.py')
-rw-r--r--searx/engines/bing_images.py8
1 files changed, 7 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