zoukankan      html  css  js  c++  java
  • 遍历CookieContainer中的cookies

     public static  List<Cookie> GetAllCookies(CookieContainer cc)
            {
                List<Cookie> lstCookies = new List<Cookie>();

                Hashtable table = (Hashtable)cc.GetType().InvokeMember("m_domainTable", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.GetField | System.Reflection.BindingFlags.Instance, null, cc, new object[] { });

                foreach (object pathList in table.Values)
                {
                    SortedList lstCookieCol = (SortedList)pathList.GetType().InvokeMember("m_list", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.GetField | System.Reflection.BindingFlags.Instance, null, pathList, new object[] { });
                    foreach (CookieCollection colCookies in lstCookieCol.Values)
                        foreach (Cookie c in colCookies) lstCookies.Add(c);
                }

                return lstCookies;
            }

    public static List<Cookie> GetAllCookies(CookieContainer cc)
    {
    List<Cookie> lstCookies = new List<Cookie>();

    Hashtable table = (Hashtable)cc.GetType().InvokeMember("m_domainTable", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.GetField | System.Reflection.BindingFlags.Instance, null, cc, new object[] { });

    Console.WriteLine("===========");
    foreach (object pathList in table.Values)
    {
    SortedList lstCookieCol = (SortedList)pathList.GetType().InvokeMember("m_list", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.GetField | System.Reflection.BindingFlags.Instance, null, pathList, new object[] { });
    foreach (CookieCollection colCookies in lstCookieCol.Values)
    foreach (Cookie c in colCookies)
    {
    Console.WriteLine(c);
    lstCookies.Add(c);
    }
    }
    Console.WriteLine("===========");

    return lstCookies;
    }

  • 相关阅读:
    四则运算2
    四则运算1
    学习进度条
    Mat数据结构
    Markdown语法
    C++继承和派生
    C++智能指针
    clion配置ROS
    视觉十四讲:第六讲_g2o图优化
    视觉十四讲:第六讲_ceres非线性优化
  • 原文地址:https://www.cnblogs.com/wcl2017/p/8458805.html
Copyright © 2011-2022 走看看