zoukankan      html  css  js  c++  java
  • WebBrowser的Cookie与HttpRequest交互 dotNET界面

    一直都在找关于如何将WebBrowser的Cookie 转化为CookieContainer

    今天发现一个简单快捷的方式 与大家分享

     HttpWebRequest httpWebRequest;
                    httpWebRequest = (HttpWebRequest)HttpWebRequest.Create(url);
                   httpWebRequest.CookieContainer = cc;
                    httpWebRequest.ContentType = contentType;
                    httpWebRequest.Referer = url;
                    httpWebRequest.Accept = accept;
                    httpWebRequest.UserAgent = userAgent;
                    httpWebRequest.Method = "GET";
                    foreach (var item in CookieString.Split(';'))
                    {
                        httpWebRequest.CookieContainer.SetCookies(new Uri(url), item);
                    }
                   

    用这种形式即可把字符串的Cookie 转化为CookieContainer 

    传给WebBrowser 直接把用httpWebRequest.CookieContainer.GetCookies(new Uri(url)); 

    这样就好了

  • 相关阅读:
    Python Day13:开放封闭原则、函数装饰器、全局局部变量
    Python Day12
    Python Day11
    Python Day10
    drf框架
    drf框架
    drf框架
    drf框架
    vue框架
    vue框架
  • 原文地址:https://www.cnblogs.com/jasondun/p/2508538.html
Copyright © 2011-2022 走看看