Exemplo n.º 1
0
 /// <summary>
 /// 登录成功回调处理
 /// </summary>
 private void LoginSuccess()
 {
     try
     {
         loginSuccessTime = DateTime.Now;
         SetTitle("登录成功!正在获取Token...");
         var visitor = new CookieMonster();
         if (Cef.GetGlobalCookieManager().VisitUrlCookies(LoginSuccessUrl, true, visitor))
         {
             visitor.WaitForAllCookies();
         }
         JArray           jsons   = new JArray();
         CookieCollection cookies = new CookieCollection();
         foreach (System.Net.Cookie cookie in visitor.NamesValues)
         {
             JObject json = new JObject();
             json["name"]   = cookie.Name;
             json["path"]   = cookie.Path;
             json["domain"] = cookie.Domain;
             json["value"]  = cookie.Value;
             jsons.Add(json);
             cookies.Add(cookie);
         }
         string cookiesJson = JsonConvert.SerializeObject(jsons);
         //页面加载完成回调
         LoginSuccessHandle?.Invoke(cookies);
         SetTitle("登录成功!获取Token成功,正在验证token...");
         HideWindow();
     }
     catch (Exception ex)
     {
         log.Error(ex);
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// 获取登录阿里妈妈的cookies
        /// </summary>
        /// <returns></returns>
        public CookieCollection GetCurrentCookies()
        {
            var visitor = new CookieMonster();

            if (Cef.GetGlobalCookieManager().VisitUrlCookies(LoginSuccessUrl, true, visitor))
            {
                visitor.WaitForAllCookies();
            }
            CookieCollection cookies = new CookieCollection();

            foreach (System.Net.Cookie cookie in visitor.NamesValues)
            {
                cookies.Add(cookie);
            }
            return(cookies);
        }
Exemplo n.º 3
0
 /// <summary>
 /// 获取所有的cookie
 /// </summary>
 /// <returns></returns>
 public List <System.Net.Cookie> GetAllCookies()
 {
     if (lstCookies == null)
     {
         lstCookies = new List <System.Net.Cookie>();
     }
     if (lstCookies.Count() <= 0)
     {
         var visitor = new CookieMonster();
         if (Cef.GetGlobalCookieManager().VisitAllCookies(visitor))
         {
             visitor.WaitForAllCookies();
         }
         foreach (System.Net.Cookie cookie in visitor.NamesValues)
         {
             lstCookies.Add(cookie);
         }
     }
     return(lstCookies);
 }
Exemplo n.º 4
0
        /// <summary>
        /// 获取淘宝账号
        /// </summary>
        public string GetTaobaoName()
        {
            var visitor = new CookieMonster();

            if (Cef.GetGlobalCookieManager().VisitUrlCookies("https://login.taobao.com/", true, visitor))
            {
                visitor.WaitForAllCookies();
            }
            string taobaoname = string.Empty;

            foreach (System.Net.Cookie cookie in visitor.NamesValues)
            {
                if (cookie.Name == "lid")
                {
                    taobaoname = cookie.Value;
                    break;
                }
            }
            return(taobaoname);
        }
Exemplo n.º 5
0
        public void LoginSuccess()
        {
            var visitor = new CookieMonster();

            if (Cef.GetGlobalCookieManager().VisitUrlCookies(LoginSuccessUrl, true, visitor))
            {
                visitor.WaitForAllCookies();
            }
            JArray jsons = new JArray();

            foreach (System.Net.Cookie cookie in visitor.NamesValues)
            {
                JObject json = new JObject();
                json["name"]   = cookie.Name;
                json["path"]   = cookie.Path;
                json["domain"] = cookie.Domain;
                json["value"]  = cookie.Value;
                jsons.Add(json);
            }
            //页面加载完成回调
            LoginSuccessHandle?.Invoke(jsons);
        }
Exemplo n.º 6
0
        /// <summary>
        /// 获取登录阿里妈妈的cookies
        /// </summary>
        public string GetCurrentCookiesToString()
        {
            var visitor = new CookieMonster();

            if (Cef.GetGlobalCookieManager().VisitUrlCookies(LoginSuccessUrl, true, visitor))
            {
                visitor.WaitForAllCookies();
            }
            JArray jsons = new JArray();

            foreach (System.Net.Cookie cookie in visitor.NamesValues)
            {
                JObject json = new JObject();
                json["name"]   = cookie.Name;
                json["path"]   = cookie.Path;
                json["domain"] = cookie.Domain;
                json["value"]  = cookie.Value;
                jsons.Add(json);
            }
            string cookiesJson = JsonConvert.SerializeObject(jsons);

            return(cookiesJson);
        }
Exemplo n.º 7
0
        /// <summary>
        /// 登录成功回调处理
        /// </summary>
        private void LoginSuccess()
        {
            SetTitle("登录成功!正在获取Token...");
            var visitor = new CookieMonster();

            if (Cef.GetGlobalCookieManager().VisitUrlCookies(LoginSuccessUrl, true, visitor))
            {
                visitor.WaitForAllCookies();
            }
            JArray           jsons   = new JArray();
            CookieCollection cookies = new CookieCollection();

            foreach (System.Net.Cookie cookie in visitor.NamesValues)
            {
                JObject json = new JObject();
                json["name"]   = cookie.Name;
                json["path"]   = cookie.Path;
                json["domain"] = cookie.Domain;
                json["value"]  = cookie.Value;
                jsons.Add(json);
                cookies.Add(cookie);
            }
            string cookiesJson = JsonConvert.SerializeObject(jsons);

            //页面加载完成回调
            LoginSuccessHandle?.Invoke(cookies);
            SetTitle("登录成功!获取Token成功,正在验证token...");
            new Thread(() =>
            {
                Thread.Sleep(3000);
                HideWindow();
            })
            {
                IsBackground = true
            }.Start();
        }