Exemple #1
0
        public static async Task <string> GetResults(Uri url)
        {
            HttpBaseProtocolFilter fiter = new HttpBaseProtocolFilter();

            fiter.IgnorableServerCertificateErrors.Add(ChainValidationResult.Expired);
            using (HttpClient hc = new HttpClient(fiter))
            {
                if (url.AbsoluteUri.Contains("23moe"))
                {
                    var ts = ApiHelper.TimeStamp.ToString();
                    EasClientDeviceInformation deviceInfo = new EasClientDeviceInformation();
                    hc.DefaultRequestHeaders.Add("client", "bilibili-uwp");
                    hc.DefaultRequestHeaders.Add("ts", ts);
                    hc.DefaultRequestHeaders.Add("appsign", MD5.GetMd5String("biliUwpXycz0423" + ts + "bilibili-uwp" + SettingHelper.GetVersion() + "0BJSDAHDUAHGAI5D45ADS5" + deviceInfo.Id.ToString()));
                    hc.DefaultRequestHeaders.Add("version", SettingHelper.GetVersion());
                    hc.DefaultRequestHeaders.Add("device-id", deviceInfo.Id.ToString());
                }

                hc.DefaultRequestHeaders.Add("user-agent", "Mozilla/5.0 BiliDroid/4.34.0 ([email protected])");
                hc.DefaultRequestHeaders.Referer = new Uri("http://www.bilibili.com/");
                HttpResponseMessage hr = await hc.GetAsync(url);

                hr.EnsureSuccessStatusCode();
                var encodeResults = await hr.Content.ReadAsBufferAsync();

                string results = Encoding.UTF8.GetString(encodeResults.ToArray());
                return(results);
            }
        }