Browse Source

[enh] better useragent string generation

Adam Tauber 11 years ago
parent
commit
71c2e8222b
1 changed files with 5 additions and 2 deletions
  1. 5 2
      searx/utils.py

+ 5 - 2
searx/utils.py

@@ -4,12 +4,15 @@ import csv
 from codecs import getincrementalencoder
 import cStringIO
 import re
+from random import choice
 
+ua_versions = ('26.0', '27.0', '28.0')
+ua_os = ('Windows NT 6.3; WOW64', 'X11; Linux x86_64; rv:26.0')
+ua = "Mozilla/5.0 ({os}) Gecko/20100101 Firefox/{version}"
 
 def gen_useragent():
     # TODO
-    ua = "Mozilla/5.0 (X11; Linux x86_64; rv:26.0) Gecko/20100101 Firefox/26.0"
-    return ua
+    return ua.format(os=choice(ua_os), version=choice(ua_versions))
 
 
 def highlight_content(content, query):