on master help sign in
fix bing "garbage" results (issue #1275)
commit75b276f408487db8fecc6eab7abd6126323a7efe authorMarc Abonce Seguin <marc-abonce@mailbox.org> dateSun 20 May 2018, 18:10 (8 years ago) parentb25dccd
2 files changed+6−3
searx/engines/bing.py+4−1 searx/utils.py+2−2
searx/engines/bing.py+4−1
@@ -16,7 +16,7 @@
1616from lxml import html
1717from searx.engines.xpath import extract_text
1818from searx.url_utils import urlencode
19−from searx.utils import match_language
19+from searx.utils import match_language, gen_useragent
2020
2121# engine dependent config
2222categories = ['general']
@@ -43,6 +43,9 @@ def request(query, params):
4343 offset=offset)
4444
4545 params['url'] = base_url + search_path
46+
47+ params['headers']['User-Agent'] = gen_useragent('Windows NT 6.3; WOW64')
48+
4649 return params
4750
4851
searx/utils.py+2−2
@@ -57,9 +57,9 @@ blocked_tags = ('script',
5757 'style')
5858
5959
60−def gen_useragent():
60+def gen_useragent(os=None):
6161 # TODO
62− return ua.format(os=choice(ua_os), version=choice(ua_versions))
62+ return ua.format(os=os or choice(ua_os), version=choice(ua_versions))
6363
6464
6565def searx_useragent():