Skip to content

Commit 8c4e4e2

Browse files
committed
Added about__user_agent/get_random_win_UserAgent.py
1 parent 49cdd25 commit 8c4e4e2

1 file changed

Lines changed: 32 additions & 0 deletions

File tree

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/usr/bin/env python3
2+
# -*- coding: utf-8 -*-
3+
4+
__author__ = 'ipetrash'
5+
6+
7+
import random
8+
9+
10+
class UserAgent:
11+
@classmethod
12+
def get_win_version(cls) -> float:
13+
return 10.0
14+
15+
@classmethod
16+
def get_chrome_version(cls) -> str:
17+
a = random.randint(40, 69)
18+
b = random.randint(2987, 3497)
19+
c = random.randint(80, 140)
20+
return '{}.0.{}.{}'.format(a, b, c)
21+
22+
@classmethod
23+
def get(cls) -> str:
24+
a = 'Mozilla/5.0 (Windows NT {}; Win64; x64)'.format(cls.get_win_version())
25+
b = 'AppleWebKit/537.36 (KHTML, like Gecko) Chrome/{} Safari/537.36'.format(cls.get_chrome_version())
26+
return '{} {}'.format(a, b)
27+
28+
29+
if __name__ == '__main__':
30+
print(UserAgent.get())
31+
# Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36
32+
# (KHTML, like Gecko) Chrome/41.0.2993.140 Safari/537.36

0 commit comments

Comments
 (0)