Sfoglia il codice sorgente

Merge 75b276f408487db8fecc6eab7abd6126323a7efe into f82ead3e303d75ba63a370dc038311e172e1330d

Marc Abonce Seguin 6 anni fa
parent
commit
82aecf72ac
No account linked to committer's email
2 ha cambiato i file con 6 aggiunte e 3 eliminazioni
  1. 4
    1
      searx/engines/bing.py
  2. 2
    2
      searx/utils.py

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

@@ -16,7 +16,7 @@
16 16
 from lxml import html
17 17
 from searx.engines.xpath import extract_text
18 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 21
 # engine dependent config
22 22
 categories = ['general']
@@ -43,6 +43,9 @@ def request(query, params):
43 43
         offset=offset)
44 44
 
45 45
     params['url'] = base_url + search_path
46
+
47
+    params['headers']['User-Agent'] = gen_useragent('Windows NT 6.3; WOW64')
48
+
46 49
     return params
47 50
 
48 51
 

+ 2
- 2
searx/utils.py Vedi File

@@ -58,9 +58,9 @@ blocked_tags = ('script',
58 58
                 'style')
59 59
 
60 60
 
61
-def gen_useragent():
61
+def gen_useragent(os=None):
62 62
     # TODO
63
-    return ua.format(os=choice(ua_os), version=choice(ua_versions))
63
+    return ua.format(os=os or choice(ua_os), version=choice(ua_versions))
64 64
 
65 65
 
66 66
 def searx_useragent():