为什么我的HttpRequest *总是*触发CDN?

时间:2018-08-18 17:05:54

标签: c# web https

我使用提琴手来模拟浏览器的请求。 在浏览器中,即使没有新Cookie,新IP也可以成功获得我想要的东西。 但是当我使用HttpRequest时,它总是返回cdn结果,这不是我所期望的,也不例外。我什至没有成功。

https://www.yczy00.com/valid_code?t=0.034255412415&user_name= 这是网址,可以更改随机数,没关系。

这就是我所做的:

public static void InitializeEnvironment()
    {
        ServicePointManager.UseNagleAlgorithm = true;
        ServicePointManager.Expect100Continue = true;
        ServicePointManager.CheckCertificateRevocationList = true;
        ServicePointManager.DefaultConnectionLimit = int.MaxValue;
        ServicePointManager.ServerCertificateValidationCallback += delegate (object sender, X509Certificate cert, X509Chain chain, SslPolicyErrors error) { return true; };
        ServicePointManager.SecurityProtocol = (SecurityProtocolType)192 | (SecurityProtocolType)768 | (SecurityProtocolType)3072;//   ServicePointManager.CheckCertificateRevocationList = true;
    }

private void Login(CookieContainer cc)
    {
        HttpWebRequest request = null;
        try
        {
            request = (HttpWebRequest)HttpWebRequest.Create(string.Format("https://www.yczy00.com/valid_code?t={0}&user_name=", RealRandom.GetRandomDouble().ToString("f16")));
            request.Method = "GET";
            request.UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:59.0) Gecko/20100101 Firefox/59.0";
            request.Accept = "*/*";
            request.Headers.Add("Accept-Language", "zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2");
            request.Headers.Add("Accept-Encoding", "gzip, deflate, br");
            request.KeepAlive = true;
            request.Headers.Add("Pragma", "no-cache");
            request.Headers.Add("Cache-Control", "no-cache");
            request.Referer = "https://www.yczy00.com/";
            request.CookieContainer = cc;
            using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
            {
                using (StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.UTF8))
                {
                    string html = reader.ReadToEnd();
                }
            }
        }
        catch (Exception ex)
        {
            MessageBox.Show(ex.Message);
        }
    }

0 个答案:

没有答案