Browse Source

fix bing "garbage" results (issue #1275)

Marc Abonce Seguin 6 years ago
parent
commit
75b276f408
2 changed files with 6 additions and 3 deletions
  1. 4
    1
      searx/engines/bing.py
  2. 2
    2
      searx/utils.py

+ 4
- 1
searx/engines/bing.py View File

16
 from lxml import html
16
 from lxml import html
17
 from searx.engines.xpath import extract_text
17
 from searx.engines.xpath import extract_text
18
 from searx.url_utils import urlencode
18
 from searx.url_utils import urlencode
19
-from searx.utils import match_language
19
+from searx.utils import match_language, gen_useragent
20
 
20
 
21
 # engine dependent config
21
 # engine dependent config
22
 categories = ['general']
22
 categories = ['general']
43
         offset=offset)
43
         offset=offset)
44
 
44
 
45
     params['url'] = base_url + search_path
45
     params['url'] = base_url + search_path
46
+
47
+    params['headers']['User-Agent'] = gen_useragent('Windows NT 6.3; WOW64')
48
+
46
     return params
49
     return params
47
 
50
 
48
 
51
 

+ 2
- 2
searx/utils.py View File

57
                 'style')
57
                 'style')
58
 
58
 
59
 
59
 
60
-def gen_useragent():
60
+def gen_useragent(os=None):
61
     # TODO
61
     # 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))
63
 
63
 
64
 
64
 
65
 def searx_useragent():
65
 def searx_useragent():