def safari(cls): saf = "{0}.{1}.{2}".format(random.randint(531, 535), random.randint(1, 50), random.randint(1, 7)) if not random.getrandbits(1): ver = "{0}.{1}".format(random.randint(4, 5), random.randint(0, 1)) else: ver = "{0}.0.{1}".format(random.randint(4, 5), random.randint(1, 5)) tmplt_win = '(Windows; U; {0}) AppleWebKit/{1} (KHTML, like Gecko)' \ ' Version/{2} Safari/{3}' tmplt_mac = '({0} rv:{1}.0; {2}) AppleWebKit/{3} (KHTML, like Gecko)' \ ' Version/{4} Safari/{5}' tmplt_ipod = '(iPod; U; CPU iPhone OS {0}_{1} like Mac OS X; {2})' \ ' AppleWebKit/{3} (KHTML, like Gecko) Version/{4}.0.5' \ ' Mobile/8B{5} Safari/6{6}' locale = MiscProvider.locale().replace('_', '-') platforms = ( tmplt_win.format(cls.windows_platform_token(), saf, ver, saf), tmplt_mac.format(cls.mac_platform_token(), random.randint(2, 6), locale, saf, ver, saf), tmplt_ipod.format(random.randint(3, 4), random.randint(0, 3), locale, saf, random.randint(3, 4), random.randint(111, 119), saf), ) return 'Mozilla/5.0 ' + cls.random_element(platforms)
def opera(cls): platform = '({0}; {1}) Presto/2.9.{2} Version/{3}.00'.format( (cls.linux_platform_token() if random.getrandbits(1) else cls.windows_platform_token()), MiscProvider.locale().replace('_', '-'), random.randint(160, 190), random.randint(10, 12), ) return 'Opera/{0}.{1}.{2}'.format( random.randint(8, 9), random.randint(10, 99), platform, )
def opera(cls): platform = '({0}; {1}) Presto/2.9.{2} Version/{3}.00'.format( ( cls.linux_platform_token() if random.getrandbits(1) else cls.windows_platform_token() ), MiscProvider.locale().replace('_', '-'), random.randint(160, 190), random.randint(10, 12), ) return 'Opera/{0}.{1}.{2}'.format( random.randint(8, 9), random.randint(10, 99), platform, )
def uuid4(cls): """ Generates a random UUID4 string. """ # Based on http://stackoverflow.com/q/41186818 return str(uuid.UUID(int=random.getrandbits(128)))
def randbool(): return True if random.getrandbits(1) else False