diff options
author | asciimoo <asciimoo@gmail.com> | 2014-01-31 04:35:23 +0100 |
---|---|---|
committer | asciimoo <asciimoo@gmail.com> | 2014-01-31 04:35:23 +0100 |
commit | 2a788c8f29f63bc069436f1a12343a47d66f2523 (patch) | |
tree | cc44113f213cd565797d3c9a87e8afe72ccf5539 /searx/engines/bing.py | |
parent | 90a93422865b81ce256ab02a367a4d3529eb2d18 (diff) | |
download | searxng-2a788c8f29f63bc069436f1a12343a47d66f2523.tar.gz searxng-2a788c8f29f63bc069436f1a12343a47d66f2523.zip |
[enh] search language support init
Diffstat (limited to 'searx/engines/bing.py')
-rw-r--r-- | searx/engines/bing.py | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/searx/engines/bing.py b/searx/engines/bing.py index ec8a0c44c..00f66b118 100644 --- a/searx/engines/bing.py +++ b/searx/engines/bing.py @@ -4,16 +4,22 @@ from cgi import escape base_url = 'http://www.bing.com/' search_string = 'search?{query}&first={offset}' -locale = 'en-US' # see http://msdn.microsoft.com/en-us/library/dd251064.aspx - paging = True +language_support = True def request(query, params): offset = (params['pageno'] - 1) * 10 + 1 + if params['language'] == 'all': + language = 'en-US' + else: + language = params['language'].replace('_', '-') search_path = search_string.format( - query=urlencode({'q': query, 'setmkt': locale}), + query=urlencode({'q': query, 'setmkt': language}), offset=offset) + + params['cookies']['SRCHHPGUSR'] = \ + 'NEWWND=0&NRSLT=-1&SRCHLANG=' + language.split('-')[0] #if params['category'] == 'images': # params['url'] = base_url + 'images/' + search_path params['url'] = base_url + search_path |