from random import randint choice def generate_ua self tpl Mozilla App

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
from random import randint, choice
def generate_ua(self):
tpl = 'Mozilla/5.0 (%s) AppleWebKit/537.36 (KHTML, like Gecho) Chrome/%s Safari/537.36'
os = 'X11; Linux x86_64'
chrome_builds = (
(32, 1700, 1749),
(33, 1750, 1846),
(34, 1847, 1915),
(35, 1916, 1984),
(36, 1985, 2061),
(37, 2062, 2124),
(38, 2125, 2170),
(39, 2171, 2213),
(40, 2214, 2271),
(41, 2272, 2310),
(42, 2311, 2357),
)
build = choice(chrome_builds)
chrome_version = '%d.0.%d.%d' % (
build[0],
randint(build[1], build[2]),
randint(0, 99),
)
return tpl % (os, chrome_version)