public static string GetAppUserAgent() { PhoneBrand brand = GetRandomPhoneBrand(false); string osVersion = GetRandomAndroidVersion(); string modelName = brand.GetRandomModel(osVersion); return("Linux; U; Android " + osVersion + "; " + modelName); }
public static PhoneBrand GetRandomPhoneBrand(bool includeApple) { double marker = 0.0; int roll = MathUtil.Random(100); for (int i = 0; i < PhoneBrandMarketShares.Length; i++) { PhoneBrand brand = (PhoneBrand)PhoneBrandMarketShares[i, 0]; double share = (double)PhoneBrandMarketShares[i, 1]; if (roll > marker && roll <= (marker + share)) { return(brand); } marker += share; } return(PhoneBrand.Apple); }
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"); }