public void Login(string email, string password) { // Flush existing cookies Cef.GetGlobalCookieManager().DeleteCookiesAsync("http://www.saltybet.com/", ""); CookieContainer cookies = SendLoginRequest(email, password); // Get the cookies for saltybet string[] cookieHeaders = cookies.GetCookieHeader(new Uri("http://www.saltybet.com")).Split(';'); foreach (string i in cookieHeaders) { // Cookie name string name = i.Split('=')[0]; // Value of cookie string value = i.Split('=')[1]; CefSharp.Cookie cookie = new CefSharp.Cookie(); cookie.Name = name; cookie.Domain = "www.saltybet.com"; cookie.Creation = DateTime.Now; cookie.Value = value; Cef.GetGlobalCookieManager().SetCookieAsync("http://www.saltybet.com/", cookie); } browser.Reload(); }
public Form1() { var settings = new CefSettings(); settings.Locale = "zh-CN"; Cef.Initialize(settings); //cookie设置 ICookieManager cookieManager = CefSharp.Cef.GetGlobalCookieManager(); CefSharp.Cookie cookie = new CefSharp.Cookie(); ReadConfigSupport read = new ReadConfigSupport("cookie", ConfigChoice.account); cookie.Domain = read.account[0]; cookie.Expires = DateTime.MaxValue; cookie.Path = read.account[1]; cookie.Name = read.account[2]; cookie.Value = read.account[3]; cookieManager.SetCookie("http://eds.newtouch.cn", cookie); string today = DateTime.Now.ToString("yyyy-MM-dd"); //ChromiumWebBrowser wb = new ChromiumWebBrowser("http://eds.newtouch.cn/eds3/StffIndex.aspx"); wb = new ChromiumWebBrowser("http://eds.newtouch.cn/eds3/worklog.aspx?LogDate=" + "2019-09-23"); if (!this.IsDisposed) { // wb.FrameLoadEnd += new EventHandler<FrameLoadEndEventArgs>(browser_FrameLoadEnd); } wb.Dock = DockStyle.Fill; this.Controls.Add(wb); }
private void visitor_SendCookie(CefSharp.Cookie obj) { try { if ((string.Compare(obj.Domain, ".movemama.com") == 0 || string.Compare(obj.Domain, ".mutantbox.com") == 0) && string.Compare(obj.Name, "user_auth") == 0) { string stri = HttpUtility.UrlDecode(obj.Value); string str = stri.Substring(stri.IndexOf(":") - 1); serializer = new Serializer(); ArrayList userAuth = (ArrayList)serializer.Deserialize(str); Hashtable info = (Hashtable)userAuth[1]; uid = info["uid"].ToString(); if (send == false) { var regValue = tool.GetRegValue("uid"); string regNewValue = uid + "^" + vs; if (regValue == null || string.Compare(regValue.ToString(), regNewValue) != 0) { tool.SetRegValue("uid", uid + "^" + vs); log("micend", "", 0); } log("micend", "", 2); send = true; } } } catch (Exception) { if (env == "test") { throw; } } }
public void SetCookie(string url, string cookiesString) { if (string.IsNullOrWhiteSpace(cookiesString)) { return; } var cookieAarray = cookiesString.Split(';'); var cookieManager = browser.GetCookieManager(); try { foreach (var cookie in cookieAarray) { //var temp = cookie.Split('='); var i = cookie.IndexOf('='); if (i != 0) { var single = new CefSharp.Cookie() { Name = cookie.Substring(0, i).Trim(), Value = cookie.Substring(i + 1), Domain = url, Path = "/", Expires = DateTime.MinValue }; cookieManager.SetCookie("http://" + url, single); } } } catch (Exception e) { } }
public bool Visit(CefSharp.Cookie cookie, int count, int total, ref bool deleteCookie) { deleteCookie = false; SendCookie?.Invoke(cookie); return(true); }
private static void DownloadFileAuth(string url, string target, Action onSuccess, Action <Exception> onFailure) { const string AuthCookieName = "auth_token"; TaskScheduler scheduler = TaskScheduler.FromCurrentSynchronizationContext(); using (ICookieManager cookies = Cef.GetGlobalCookieManager()){ cookies.VisitUrlCookiesAsync(url, true).ContinueWith(task => { string cookieStr = null; if (task.Status == TaskStatus.RanToCompletion) { Cookie found = task.Result?.Find(cookie => cookie.Name == AuthCookieName); // the list may be null if (found != null) { cookieStr = $"{found.Name}={found.Value}"; } } WebClient client = WebUtils.NewClient(BrowserUtils.UserAgentChrome); client.Headers[HttpRequestHeader.Cookie] = cookieStr; client.DownloadFileCompleted += WebUtils.FileDownloadCallback(target, onSuccess, onFailure); client.DownloadFileAsync(new Uri(url), target); }, scheduler); } }
private async void OnNavigated(object sender, AddressChangedEventArgs args) { string url = args.Address; if (url.Contains("/home")) { var cookieManager = Cef.GetGlobalCookieManager(); await cookieManager.VisitAllCookiesAsync().ContinueWith(t => { if (t.Status == TaskStatus.RanToCompletion) { List <Cookie> cookies = t.Result; Cookie RSec = cookies.Find(x => x.Name == ".ROBLOSECURITY"); if (RSec != null) { SecurityToken = RSec.Value; chromeBrowser.Load("https://www.roblox.com/my/account/json"); } } }); } }
public static void UpdateCookie(this IBrowser Browser, CefSharp.Cookie Cookie) { try { AsyncContext.Run(async() => await Cef.GetGlobalCookieManager().SetCookieAsync(Browser.MainFrame.Url, Cookie)); } catch { } }
public bool Visit(CefSharp.Cookie cookie, int count, int total, ref bool deleteCookie) { deleteCookie = false; if (SendCookie != null) { SendCookie(cookie); } return true; }
public bool Visit(CefSharp.Cookie cookie, int count, int total, ref bool deleteCookie) { cookies.Add(new Tuple<string, string>(cookie.Name, cookie.Value)); if (count == total - 1) useAllCookies(cookies); return true; }
public bool Visit(CefSharp.Cookie cookie, int count, int total, ref bool deleteCookie) { cookies.Add(cookie); if (count == total - 1) { gotAllCookies.Set(); } return(true); }
bool ICookieVisitor.Visit(Cookie cookie, int count, int total, ref bool deleteCookie) { list.Add(cookie); if(count == (total - 1)) { //Set the result on the ThreadPool so the Task continuation is not run on the CEF UI Thread taskCompletionSource.TrySetResultAsync(list); } return true; }
public bool Visit(CefSharp.Cookie cookie, int count, int total, ref bool deleteCookie) { //https://kyfw.12306.cn/passport/web/login 提取cookie,但是该请求的URL是啥 //此处调用前需要先过滤URL visitor_SendCookie(cookie); deleteCookie = false; if (SendCookie != null) { SendCookie(cookie); } return(true); }
protected CefSharp.Cookie ConvertCookie(System.Net.Cookie cookie) { var c = new CefSharp.Cookie(); c.Creation = cookie.TimeStamp; c.Domain = cookie.Domain; c.Expires = cookie.Expires; c.HttpOnly = cookie.HttpOnly; c.Name = cookie.Name; c.Path = cookie.Path; c.Secure = cookie.Secure; c.Value = cookie.Value; return(c); }
private void visitor_SendCookie(CefSharp.Cookie obj) { try { initCookieContainer.Add(new System.Net.Cookie(obj.Name, obj.Value) { Domain = obj.Domain }); cookies += obj.Domain.TrimStart('.') + "^" + obj.Name + "^" + obj.Value + "$"; } catch (Exception) { } }
/// <summary> /// /// </summary> /// <param name="cookie"></param> /// <param name="count">第几个</param> /// <param name="total"></param> /// <param name="deleteCookie"></param> /// <returns></returns> public bool Visit(CefSharp.Cookie cookie, int count, int total, ref bool deleteCookie) { FormBrowser.cookieList.Add(new CookiePseudo() { Creation = cookie.Creation, Domain = cookie.Domain, Expires = cookie.Expires, HttpOnly = cookie.HttpOnly, LastAccess = cookie.LastAccess, Name = cookie.Name, Path = cookie.Path, Secure = cookie.Secure, Value = cookie.Value }); return(true); }
protected CefSharp.Cookie ConvertCookie(System.Net.Cookie cookie) { var c = new CefSharp.Cookie { Creation = cookie.TimeStamp, Domain = cookie.Domain, Expires = cookie.Expires, HttpOnly = cookie.HttpOnly, Name = cookie.Name, Path = cookie.Path, Secure = cookie.Secure, Value = cookie.Value }; return(c); }
public bool Visit(CefSharp.Cookie cookie, int count, int total, ref bool deleteCookie) { Cookies.Add(new Cookie { Name = cookie.Name, Value = cookie.Value, Domain = cookie.Domain, Path = cookie.Path }); if (count == total) { _source.SetResult(Cookies); } deleteCookie = false; return(true); }
public bool Visit(CefSharp.Cookie cookie, int count, int total, ref bool deleteCookie) { cookies.Add(new System.Net.Cookie() { Name = cookie.Name, Path = cookie.Path, Domain = cookie.Domain, Value = cookie.Value }); if (count == total - 1) { gotAllCookies.Set(); } return(true); }
bool ICookieVisitor.Visit(CefSharp.Cookie cookie, int count, int total, ref bool deleteCookie) { try { deleteCookie = false; if (cookie.Domain == null || cookie.Name == null) { return(true); } Debug.WriteLine(cookie.Name + ", " + cookie.Value + ", " + cookie.Domain + ", " + cookie.Path); Request.CookieContainer.Add(new System.Net.Cookie(cookie.Name, cookie.Value, cookie.Path, cookie.Domain)); IsFinished = count == total - 1; } catch (Exception e) { Telemetry.Default.TrackException(e); } return(true); }
public bool Visit(Cookie cookie, int count, int total, ref bool deleteCookie) { if (_filter == null) { deleteCookie = true; } else { var conv = new Helpers.Cookie { Name = cookie.Name, Domain = cookie.Domain, Value = cookie.Value, Path = cookie.Path }; if (_filter(conv)) { deleteCookie = true; } } return(true); }
public bool Visit(CefSharp.Cookie cookie, int count, int total, ref bool deleteCookie) { deleteCookie = false; string key = cookie.Domain.TrimStart('.') + "___" + cookie.Name; string value = cookie.Value; if (!string.IsNullOrEmpty(this.cookieString)) { this.cookieString += "$$$"; } this.cookieString += key + "|||" + value; Dictionary <string, string> dic = new Dictionary <string, string>(); string[] cookieArray = this.cookieString.Split(new string[] { "$$$" }, StringSplitOptions.None); foreach (string item in cookieArray) { string[] itemArray = item.Split(new string[] { "|||" }, StringSplitOptions.None); string cookieName = itemArray[0]; string cookieValue = itemArray[1]; if (dic.ContainsKey(cookieName)) { dic[cookieName] = cookieValue; } else { dic.Add(cookieName, cookieValue); } } string temp = ""; foreach (var item in dic) { temp += item.Key + "|||" + item.Value + "$$$"; } if (temp.Length > 0) { temp = temp.Remove(temp.Length - 3); } this.cookieString = temp; return(true); }
public void SetCookie(string url, List <CookiePseudo> cookies) { var cookieManager = browser.GetCookieManager(); foreach (var item in cookies) { var cookie = new CefSharp.Cookie() { Creation = item.Creation, Domain = item.Domain, Expires = item.Expires, HttpOnly = item.HttpOnly, LastAccess = item.LastAccess, Name = item.Name, Path = item.Path, Secure = item.Secure, Value = item.Value }; cookieManager.SetCookie("http://" + url, cookie); } }
/// <summary> /// 设置cookie信息 /// </summary> /// <param name="url"></param> /// <param name="cookies"></param> public static void SetCefCookies(string url, CookieCollection cookies) { Cef.GetGlobalCookieManager().SetStoragePath(Environment.CurrentDirectory, true); foreach (System.Net.Cookie c in cookies) { var cookie = new CefSharp.Cookie { Creation = DateTime.Now, Domain = c.Domain, Name = c.Name, Value = c.Value, Expires = c.Expires }; Task <bool> task = Cef.GetGlobalCookieManager().SetCookieAsync(url, cookie); while (!task.IsCompleted) { continue; } bool b = task.Result; } }
public bool Visit(CefSharp.Cookie cookie, int count, int total, ref bool deleteCookie) { GClass8 class2 = this; lock (class2) { if (this.dictionary_0.ContainsKey(cookie.Name)) { this.dictionary_0[cookie.Name] = new System.Net.Cookie(cookie.Name, cookie.Value, cookie.Path, cookie.Domain); this.dictionary_0[cookie.Name].Name = cookie.Name; this.dictionary_0[cookie.Name].Value = cookie.Value; this.dictionary_0[cookie.Name].Path = cookie.Path; this.dictionary_0[cookie.Name].Domain = cookie.Domain; } else { this.dictionary_0.Add(cookie.Name, new System.Net.Cookie(cookie.Name, cookie.Value, cookie.Path, cookie.Domain)); } this.method_2(count == (total - 1)); } return(true); }
public FrmMain() { AppDomain.CurrentDomain.AssemblyResolve += Resolver; InitializeComponent(); CreateConsole(); var settings = new CefSettings() { CachePath = Path.Combine(AppPath, @"Cache"), UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.93 Safari/537.36 Edg/90.0.818.51" }; Cef.Initialize(settings, performDependencyCheck: true, browserProcessHandler: null); var mngr = Cef.GetGlobalCookieManager(); mngr.DeleteCookies("https://topescortbabes.com"); CefSharp.Cookie Ac = new CefSharp.Cookie { HttpOnly = false, Name = "plus18", Value = "1", Expires = new DateTime().AddYears(1), Path = "/", Domain = ".topescortbabes.com" }; var result = mngr.SetCookie("https://topescortbabes.com", Ac); if (!result) { LogError("Unable to set cookie 'plus18' on 'topescortbabes.com'"); } browser = new OffScreenBrowser(); }
private static void DownloadFileAuth(string url, string target, Action onSuccess, Action <Exception> onFailure) { const string AuthCookieName = "auth_token"; TaskScheduler scheduler = TaskScheduler.FromCurrentSynchronizationContext(); using (ICookieManager cookies = Cef.GetGlobalCookieManager()){ cookies.VisitUrlCookiesAsync(url, true).ContinueWith(task => { string cookieStr = null; if (task.Status == TaskStatus.RanToCompletion) { Cookie found = task.Result?.Find(cookie => cookie.Name == AuthCookieName); // the list may be null if (found != null) { cookieStr = $"{found.Name}={found.Value}"; } } BrowserUtils.DownloadFileAsync(url, target, cookieStr, onSuccess, onFailure); }, scheduler); } }
/// 回调事件 public void visitor_SendCookie(CefSharp.Cookie obj) { string domain = obj.Domain; #region cookie 替换 System.Net.Cookie ck = new System.Net.Cookie(obj.Name, obj.Value, obj.Path, obj.Domain); if (!CookieDict.ContainsKey(domain)) { Dictionary <string, System.Net.Cookie> cookies = new Dictionary <string, System.Net.Cookie>(); CookieDict.Add(domain, cookies); } if (!CookieDict[domain].ContainsKey(obj.Name)) { CookieDict[domain].Add(obj.Name, ck); } CookieDict[domain][obj.Name] = ck; Dictionary <string, string> dict = SystemConfig.SampleCookieItem; if (dict.ContainsKey(obj.Name)) { string newItem = dict[obj.Name]; //判断是否增加新项 System.Net.Cookie generate = new System.Net.Cookie(newItem, obj.Value, obj.Path, obj.Domain); if (!CookieDict[domain].ContainsKey(newItem)) { CookieDict[domain].Add(newItem, generate); } CookieDict[domain][newItem] = generate; } if (!obj.Domain.Contains(SystemConfig.CookieDomain)) { return; } #endregion string cookie = "Domain:" + obj.Domain.TrimStart('.') + "\r\n" + obj.Name + ":" + obj.Value; }
bool IResourceHandler.CanSetCookie(Cookie cookie) { return true; }
public bool Visit(Cookie cookie, int count, int total, ref bool deleteCookie) { deleteCookie = true; return(true); }
private void visitor_SendCookie(CefSharp.Cookie obj) { //此处处理cookie cookies.Append(obj.Domain.TrimStart('.') + "^" + obj.Name + "^" + obj.Value + "$"); }
// // Summary: // Return true if the specified cookie returned with the response can be set // or false otherwise. public bool CanSetCookie(CefSharp.Cookie cookie) { return(true); }
public bool Visit(Cookie cookie, int count, int total, ref bool deleteCookie) { deleteCookie = true; return true; }