Exemple #1
0
        public static BrowserBrand GetRandomBrowserBrand()
        {
            double marker = 0.0;
            int    roll   = MathUtil.Random(100);

            for (int i = 0; i < BROWSER_BRANDS.Length; i++)
            {
                BrowserBrand brand = (BrowserBrand)BROWSER_BRANDS[i, 0];
                double       share = (double)BROWSER_BRANDS[i, 1];

                if (roll > marker && roll <= (marker + share))
                {
                    return(brand);
                }
                marker += share;
            }
            return(BrowserBrand.Chrome);
        }
Exemple #2
0
        public static string GetMobileUserAgent()
        {
            PhoneBrand brand = GetRandomPhoneBrand();

            if (brand == PhoneBrand.Apple)
            {
                return("Mozilla/5.0 (iPhone; CPU iPhone OS " + GetRandomIOSVersion()
                       + " like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/"
                       + BrowserBrand.Safari.GetRandomVersion() + " Mobile/15E148 Safari/604.1");
            }
            string       osVersion      = GetRandomAndroidVersion();
            BrowserBrand browser        = GetRandomBrowserBrand();
            string       browserVersion = browser.GetRandomVersion();

            if (browser == BrowserBrand.Firefox)
            {
                return("Mozilla/5.0 (Android " + osVersion + "; Mobile; rv:" + browserVersion + ") Gecko/" + browserVersion + " Firefox/" + browserVersion);
            }
            string modelName = brand.GetRandomModel(osVersion);

            return("Mozilla/5.0 (Linux; Android " + osVersion + "; " + modelName + " AppleWebKit/537.36 (KHTML, like Gecko) Chrome/" + browserVersion + " Mobile Safari/537.36");
        }