summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam Tauber <asciimoo@gmail.com>2018-07-09 11:00:37 +0200
committerGitHub <noreply@github.com>2018-07-09 11:00:37 +0200
commitd51732c0e5e89f86abfe68718277a2e21b190103 (patch)
tree9b6cc22151b8a8fbd9e74595c092a681ea765b39
parent736f0fff0eeaded50d02f2f989fc3a4c638b3d3c (diff)
parent75b276f408487db8fecc6eab7abd6126323a7efe (diff)
downloadsearxng-d51732c0e5e89f86abfe68718277a2e21b190103.tar.gz
searxng-d51732c0e5e89f86abfe68718277a2e21b190103.zip
Merge pull request #1303 from MarcAbonce/bing
Fix bing "garbage" results
-rw-r--r--searx/engines/bing.py5
-rw-r--r--searx/utils.py4
2 files changed, 6 insertions, 3 deletions
diff --git a/searx/engines/bing.py b/searx/engines/bing.py
index c6d41782b..2da40619d 100644
--- a/searx/engines/bing.py
+++ b/searx/engines/bing.py
@@ -16,7 +16,7 @@
from lxml import html
from searx.engines.xpath import extract_text
from searx.url_utils import urlencode
-from searx.utils import match_language
+from searx.utils import match_language, gen_useragent
# engine dependent config
categories = ['general']
@@ -43,6 +43,9 @@ def request(query, params):
offset=offset)
params['url'] = base_url + search_path
+
+ params['headers']['User-Agent'] = gen_useragent('Windows NT 6.3; WOW64')
+
return params
diff --git a/searx/utils.py b/searx/utils.py
index 3b2e39919..bd6c3fe2f 100644
--- a/searx/utils.py
+++ b/searx/utils.py
@@ -59,9 +59,9 @@ blocked_tags = ('script',
'style')
-def gen_useragent():
+def gen_useragent(os=None):
# TODO
- return ua.format(os=choice(ua_os), version=choice(ua_versions))
+ return ua.format(os=os or choice(ua_os), version=choice(ua_versions))
def searx_useragent():