using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using AllBase; using CefSharp.WinForms; using CefSharp; using Work; using System.Threading; using Work.CollectClass; using Work.Api; using LittleRabbit.LittleRabbitForms.BaseForms; namespace LittleRabbit.LittleRabbitForms { public partial class IeForm : LRBaseForm { public string Url = ""; public string skipUrl = ""; public bool isSlide = false; public bool isExecJsSuccess = false; public string x5Sec = ""; public string Title { get { return Text; } set { Text = value; } } public string UrlString { get { return Url; } set { Url = value; } } public IeForm() { InitializeComponent(); } public IeForm(string _url) { Url = _url; InitializeComponent(); } public ChromiumWebBrowser cefWebBrowser3; private void IeForm_Load(object sender, EventArgs e) { if (BaseClass.Ico != null) Icon = BaseClass.Ico; if (string.IsNullOrEmpty(Url)) { cefWebBrowser3 = new ChromiumWebBrowser("https://login.taobao.com/member/login.jhtml?style=mini&newMini2=true&redirectURL=https://s.taobao.com/search?q=se&imgfile=&commend=all&ssid=s5-e&search_type=item&sourceId=tb.index&spm=a21bo.2017.201856-taobao-item.1&ie=utf8&initiative_id=tbindexz_20170306"); StartPosition = FormStartPosition.CenterScreen; } else { if (string.IsNullOrEmpty(TitleText)) { Location = new Point(330, 220); TitleText = Text = "账号登录"; cefWebBrowser3 = new ChromiumWebBrowser(Url); } else { cefWebBrowser3 = new ChromiumWebBrowser(Url); Text = TitleText; } } RequestContextSettings requestContextSettings = new RequestContextSettings(); requestContextSettings.PersistSessionCookies = false; requestContextSettings.PersistUserPreferences = false; cefWebBrowser3.RequestContext = new RequestContext(requestContextSettings); cefWebBrowser3.Dock = DockStyle.Fill; cefWebBrowser3.AutoSize = true; cefWebBrowser3.FrameLoadEnd += CefWebBrowser3_FrameLoadEnd; cefWebBrowser3.AddressChanged += CefWebBrowser3_AddressChanged; cefWebBrowser3.AddressChanged += cefWebBrowser3_UrlChanged; cefWebBrowser3.BrowserSettings = new BrowserSettings { Plugins = CefState.Disabled }; panel2.Controls.Add(cefWebBrowser3); DelCookies(); ChromeCookies = ""; new Thread(ReflashCookies).Start(); new Thread(ResetUserList).Start(); new Thread(SetTaoBaoCookies).Start(); new Thread(AutoRrefreshCookies).Start(); } public void SetTaoBaoCookies() { if (TaobaoMobileCollect.CookiesDic.Count > 0) { foreach (var kvp in TaobaoMobileCollect.CookiesDic) { AddList(kvp.Key, kvp.Value, 1); } } } private void ResetUserList() { Thread.Sleep(100); if (this.userComboBox.InvokeRequired) { this.Invoke(new Action(() => { userComboBox.Items.Clear(); })); } else { userComboBox.Items.Clear(); } try { foreach (KeyValuePair item in UserCookies) { if (this.userComboBox.InvokeRequired) { this.Invoke(new Action(() => { if (!userComboBox.Items.Contains(item.Key)) userComboBox.Items.Add(item.Key); })); } else { if (userComboBox.Items.Contains(item.Key)) continue; userComboBox.Items.Add(item.Key); } } } catch { } if (this.userComboBox.InvokeRequired) { this.Invoke(new Action(() => { userComboBox.Text = SetCookiesUserInfo.UserName; })); } else { userComboBox.Text = SetCookiesUserInfo.UserName; } } private void CefWebBrowser3_AddressChanged(object sender, AddressChangedEventArgs e) { Url = e.Address; } /// /// 限制滑块自动拖动次数 /// private int iTryTimes = 0; private Random random = new Random(); private int _locX; private int _locY; public bool isDoing = false; public bool LoginOk = false; public bool tradeOk = false; #region 获取网页js /// /// 获取网页某元素坐标X /// private string sJsGetElementPageLeft = @"function getElementPageLeft(element) { var actualLeft = element.offsetLeft; var parent = element.offsetParent; while (parent != null) { actualLeft += parent.offsetLeft + (parent.offsetWidth - parent.clientWidth) / 2; parent = parent.offsetParent; } return actualLeft; }; getElementPageLeft(document.getElementById('nc_1_n1t'));"; /// /// 获取网页某元素坐标Y /// private string sJsGetElementPageTop = @"function getElementPageTop(element) { var actualTop=element.offsetTop; var parent=element.offsetParent; while(parent!=null) { actualTop+=parent.offsetTop+(parent.offsetHeight-parent.clientHeight)/2; parent=parent.offsetParent; } return actualTop; }; getElementPageTop(document.getElementById('nc_1_n1t'))"; #endregion private void CefWebBrowser3_FrameLoadEnd(object sender, CefSharp.FrameLoadEndEventArgs e) { if (!cefWebBrowser3.IsBrowserInitialized) return; Task.Run(() => { var t = cefWebBrowser3.GetBrowser().MainFrame.EvaluateScriptAsync("document.getElementById('J_Quick2Static').click();"); t.Wait(2500); string url = cefWebBrowser3.Address; string loginOkUrl = "https://s.taobao.com/search?q=se"; if ((url.Contains(loginOkUrl) && url.IndexOf(loginOkUrl) == 0) || url.Contains("https://buyertrade.taobao.com")) //登录成功 { try { if (!LoginOk) { LoginOk = true; new Thread(GetLoginUserName).Start(); Hide(); } } catch { } } if (url.Contains("acs.m.taobao.com")) { var lst = UserCookies.ToList(); for (int i = 0; i < lst.Count; i++) { DelCookies(); SetTaoBao(lst[i].Key, true); } } if (url.Contains("www.taobao.com")) { if (!tradeOk) { tradeOk = true; cefWebBrowser3.Load("https://trade-acs.m.taobao.com"); } } if (url.Contains("nc_session_id")) { cefWebBrowser3.Load("https://www.taobao.com/"); } }); } public static Dictionary UserCookies = new Dictionary(); private void GetLoginUserName() { Thread.Sleep(2000); string url = "https://i.taobao.com/my_taobao.htm"; string refere = "https://login.taobao.com/member/login.jhtml"; if (string.IsNullOrEmpty(ChromeCookies)) ChromeCookies = cookiesSrt; string html = GetPostTaobaoHtml.UploadTaobao(url, refere, true, ChromeCookies); string name = BaseRegex.GetMatchRegexString(ref html, @"[\s]*[\(]([\w]+)[\)]"); if (string.IsNullOrEmpty(name)) name = BaseRegex.GetMatchRegexString(ref ChromeCookies, @"dnk=([\w\W]+?);"); if (string.IsNullOrEmpty(name)) name = BaseRegex.GetMatchRegexString(ref ChromeCookies, @"_nk_=([\w\W]+?);"); if (string.IsNullOrEmpty(name)) return; //if (!BaseClass.CookiesAll.ContainsKey("taobao.com")) // return; if (string.IsNullOrEmpty(ChromeCookies)) return; //if (TaobaoMobileCollect.CookiesDic.Count>0&&TaobaoMobileCollect.CookiesDic[name].Contains("x5sec")) //{ // string cookies = TaobaoMobileCollect.CookiesDic[name].ToString(); // BaseClass.x5Sec = BaseRegex.GetMatchRegexString(ref cookies, @"x5sec=([\w\W]+?);"); // ChromeCookies += "x5sec=" + BaseClass.x5Sec + ";"; //} if (name.Contains("%")) name = GetHtml.UrlDecode(name); TaobaoMobileCollect.CookiesDic[name] = ChromeCookies; AddList(name, ChromeCookies, 1); SaveCookies(); } public static void SaveCookies() { string temp = ""; foreach (var item in TaobaoMobileCollect.CookiesDic) { temp += item.Key + "-----" + item.Value + "\r\n"; } FileBase.WriteAllText("temp/taobaocookies.txt", temp); } public void AddList(string name, string cookies, int site_id) { try { string[] l = cookies.Split(';'); List cookie = new List(); for (int j = 0; j < l.Length; j++) { if (string.IsNullOrEmpty(l[j]) || !l[j].Contains("=")) continue; string[] ll = l[j].Split('='); if (site_id == 1) { System.Net.Cookie c = new System.Net.Cookie(); c.Domain = "taobao.com"; c.Expires = DateTime.Now.AddYears(1); c.Name = ll[0].Trim(); c.Value = ll[1]; c.Path = "/"; cookie.Add(c); } } UserCookies uc = new UserCookies(); uc.Cookies = cookie; uc.UserName = name; uc.SiteId = site_id; if (!UserCookies.ContainsKey(name)) UserCookies.Add(name, uc); else UserCookies[name] = uc; SetCookiesUserInfo.UserName = name; ResetUserList(); } catch { } } /// /// 模拟鼠标拖拽 /// /// 浏览器Host /// 起始坐标X /// 起始坐标Y /// 终止坐标X /// 终止坐标Y public void CefMouseDrag(IBrowserHost host, int x1, int y1, int x2, int y2) { Random random = new Random(); host.SendMouseClickEvent(x1, y1, MouseButtonType.Left, false, 1, CefEventFlags.None);//按下鼠标左键 Thread.Sleep(random.Next(5)); double x = x1; double y = y1; int xlen = x2 - x1; while (x < x2) { int rs = random.Next(9, 15); if (x2 - x > (xlen - xlen / 3)) { rs = random.Next(3); } x = x + rs; Thread.Sleep(1 + random.Next(rs)); host.SendMouseMoveEvent((int)x, (int)y, false, CefEventFlags.LeftMouseButton); // 移动鼠标 } host.SendMouseClickEvent(x2, y2, MouseButtonType.Left, true, 1, CefEventFlags.None); // 抬起鼠标左键 } private void panelSettleSlide_Click_1(object sender, EventArgs e) { TbSettleSlideForm tbForm = new TbSettleSlideForm(); //tbForm.freshType = 2; tbForm.slideUrl = Url; tbForm.tbDetailForm = this; tbForm.Show(); } private void userComboBox_SelectedIndexChanged_1(object sender, EventArgs e) { string url = cefWebBrowser3.Address; if (SetCookiesUserInfo.UserName == userComboBox.Text && !url.Contains("login")) return; SetTaoBao(userComboBox.Text, true); LoginOk = false; cefWebBrowser3.Load("https://s.taobao.com/search?q=se"); } private void delCookiesButtonX_Click_1(object sender, EventArgs e) { string cboname = userComboBox.Text; Task.Run(() => { UserCookies.Remove(cboname); if (UserCookies.Count > 0) SetCookiesUserInfo.UserName = UserCookies.FirstOrDefault().Key; else SetCookiesUserInfo.UserName = ""; TaobaoMobileCollect.CookiesDic.Remove(cboname); TaobaoMobileCollect.CookiesDic.Clear(); DelCookies(); ChromeCookies = ""; BaseClass.IeFormCookies = ""; ResetUserList(); SaveCookies(); SetTaoBao(SetCookiesUserInfo.UserName, true); LoginOk = false; cefWebBrowser3.Load("https://login.taobao.com/member/login.jhtml?style=mini&newMini2=true&redirectURL=https://s.taobao.com/search?q=se&imgfile=&commend=all&ssid=s5-e&search_type=item&sourceId=tb.index&spm=a21bo.2017.201856-taobao-item.1&ie=utf8&initiative_id=tbindexz_20170306"); }); } public override void PictureBox1_Click(object sender, EventArgs e) { if (Text == "淘宝验证窗口") { if (userComboBox.SelectedItem == null) Thread.Sleep(3000); this.Close(); } else { Hide(); return; } } #region 添加x5sec事件 public void ExecX5secJs() { if (cefWebBrowser3 != null && cefWebBrowser3.IsBrowserInitialized) { string js = @"function setCookie(name,value) { var Days = 30; var exp = new Date(); exp.setTime(exp.getTime() + Days * 24 * 60 * 60 * 1000); document.cookie = name + '=' + escape(value) + ';path=/;expires=' + exp.toGMTString(); } "; js += @"function getCookie(name) { var arr, reg = new RegExp('(^| )' + name + '=([^;]*)(;|$)'); if (arr = document.cookie.match(reg)) return unescape(arr[2]); else return null; } "; js += @"function delCookie(name) { var exp = new Date(); exp.setTime(exp.getTime() - 1); var cval = getCookie(name); if (cval != null) document.cookie = name + '=' + cval + ';expires=' + exp.toGMTString(); } "; var task = cefWebBrowser3.GetBrowser().MainFrame.EvaluateScriptAsync(js); task.Wait(); var result = task.Result.Success; if (result) { js = "setCookie('x5sec','" + x5Sec + "')"; task = cefWebBrowser3.GetBrowser().MainFrame.EvaluateScriptAsync(js); task.Wait(); if (task.Result.Success) { isExecJsSuccess = true; cefWebBrowser3.Reload(); } } } } #endregion private void panelSettleSlide_Click(object sender, EventArgs e) { TbSettleSlideForm tbForm = new TbSettleSlideForm(); //tbForm.freshType = 2; tbForm.slideUrl = Url; tbForm.tbDetailForm = this; tbForm.Show(); } private void cefWebBrowser3_UrlChanged(object sender, CefSharp.AddressChangedEventArgs e) { if (InvokeRequired) { Invoke(new Action(() => { skipUrl = cefWebBrowser3.Address; })); } else { skipUrl = cefWebBrowser3.Address; } } private void panelBack_Click(object sender, EventArgs e) { if (cefWebBrowser3.IsBrowserInitialized && cefWebBrowser3.CanGoBack) { cefWebBrowser3.Back(); } } private void panelForward_Click(object sender, EventArgs e) { if (cefWebBrowser3.IsBrowserInitialized && cefWebBrowser3.CanGoForward) { cefWebBrowser3.Forward(); } } private void panelRefresh_Click(object sender, EventArgs e) { if (!string.IsNullOrEmpty(skipUrl)) { cefWebBrowser3.Load(skipUrl); } else { cefWebBrowser3.Load(Url); } cefWebBrowser3.Refresh(); } private void wwPictureBox_Click(object sender, EventArgs e) { } bool isH5 = false; private void userComboBox_SelectedIndexChanged(object sender, EventArgs e) { if (Url.Contains("https://login.m.taobao.com/") || Url.Contains("https://acs.m.taobao.com//h5")) { isH5 = true; return; } if (isH5) return; string url = cefWebBrowser3.Address; if (SetCookiesUserInfo.UserName == userComboBox.Text && !url.Contains("login")) return; SetTaoBao(userComboBox.Text, true); LoginOk = false; cefWebBrowser3.Load("https://s.taobao.com/search?q=se"); } public bool SetTaoBao(string userName, bool refundFlag) { if (!UserCookies.ContainsKey(userName)) { if (string.IsNullOrEmpty(userName)) DeleteTaoBao(); //MessageBox.Show("没有找到这个淘宝买家", "提示"); return false; } DeleteTaoBao(); //var cookieManager = CefSharp.Cef.GetGlobalCookieManager(); var cookieManager = cefWebBrowser3.RequestContext.GetCookieManager(null); //List cookies =UserCookies[userName].Cookies; //Cef.GetGlobalCookieManager().SetStoragePath(Environment.CurrentDirectory, true); //BaseClass.IeFormCookies string[] l = BaseClass.IeFormCookies.Split(';'); List cookies = new List(); for (int j = 0; j < l.Length; j++) { if (string.IsNullOrEmpty(l[j]) || !l[j].Contains("=")) continue; string[] ll = l[j].Split('='); System.Net.Cookie c = new System.Net.Cookie(); c.Domain = "taobao.com"; c.Expires = DateTime.Now.AddYears(1); c.Name = ll[0].Trim(); c.Value = ll[1]; c.Path = "/"; cookies.Add(c); } string domain = "https://s.taobao.com/search?q=se"; foreach (System.Net.Cookie c in cookies) { var cookie = new CefSharp.Cookie { Domain = c.Domain, Name = c.Name, Value = c.Value, Expires = DateTime.Now.AddYears(1), Path = "/" }; Task task = cookieManager.SetCookieAsync(domain, cookie); while (!task.IsCompleted) { Thread.Sleep(1); continue; } } if (!refundFlag) { BaseMsgForm.ShowInfo("切换到账户:" + userName + " 成功", "提示"); } SetCookiesUserInfo.UserName = userName; return true; } public void DeleteTaoBao() { var cookieManager = cefWebBrowser3.RequestContext.GetCookieManager(null); ; if (!string.IsNullOrEmpty(ChromeCookies)) { var cookies = ChromeCookies;// BaseClass.CookiesAllString["taobao.com"]; string[] l = cookies.Split(';'); for (int i = 0; i < l.Length; i++) { if (string.IsNullOrEmpty(l[i]) || !l[i].Contains("=")) continue; string name = l[i].Split('=')[0].Trim(); try { cookieManager.DeleteCookies("https://s.taobao.com/search?q=se", name); cookieManager.DeleteCookies("https://login.taobao.com/member/login.jhtml", name); //cookieManager.Dispose(); } catch { } } } } public void DelCookies() { ICookieManager cookieManager = null; if (this.cefWebBrowser3 != null && this.cefWebBrowser3.RequestContext != null) cookieManager = this.cefWebBrowser3.RequestContext.GetCookieManager(null); else cookieManager = Cef.GetGlobalCookieManager(); Task deleteTask = cookieManager.DeleteCookiesAsync("taobao.com", null); deleteTask.Wait(); } private void buttonEx4_Click(object sender, EventArgs e) { DelCookies(); LoginOk = false; cefWebBrowser3.Load("https://login.taobao.com/member/login.jhtml?style=mini&newMini2=true&redirectURL=https://s.taobao.com/search?q=se&imgfile=&commend=all&ssid=s5-e&search_type=item&sourceId=tb.index&spm=a21bo.2017.201856-taobao-item.1&ie=utf8&initiative_id=tbindexz_20170306"); } private void buttonX2_Click(object sender, EventArgs e) { DelCookies(); LoginOk = false; cefWebBrowser3.Load("https://login.taobao.com/member/login.jhtml?style=mini&newMini2=true&redirectURL=https://s.taobao.com/search?q=se&imgfile=&commend=all&ssid=s5-e&search_type=item&sourceId=tb.index&spm=a21bo.2017.201856-taobao-item.1&ie=utf8&initiative_id=tbindexz_20170306"); } public static string ChromeCookies = ""; public static string oldSec = ""; public static string cookiesSrt = ""; public delegate void delegateView(); public void ReflashCookies() { try { while (true) { Thread.Sleep(300); if (this == null || this.IsDisposed) return; Invoke(new delegateView(GetCookies)); Thread.Sleep(300); string cookie = ""; for (int i = 0; i < cookies.Count; i++)//初始化COOKIES缓存 { var c = cookies[i]; if (!c.Domain.Contains("taobao.com")) continue; cookie += c.Name + "=" + c.Value + "; "; string mainDomain = GetHtml.GetMainDomain(c.Domain); if (BaseClass.CookiesAll.ContainsKey(mainDomain)) { if (BaseClass.CookiesAll[mainDomain].ContainsKey(c.Name)) BaseClass.CookiesAll[mainDomain][c.Name] = c.Value; else BaseClass.CookiesAll[mainDomain].Add(c.Name, c.Value); } else { BaseClass.CookiesAll.Add(mainDomain, new Dictionary()); BaseClass.CookiesAll[mainDomain].Add(c.Name, c.Value); } } if (!string.IsNullOrEmpty(cookie)) { if (cookie.Contains("x5sec")) cookiesSrt = cookie; //if (cookie.Contains("x5sec")&&(cookie.Contains("tracknick") || cookie.Contains("dnk") || cookie.Contains("_w_tb_nick"))) // BaseClass.IeFormCookies = ChromeCookies = cookie; //cookiesSrt = cookie; if ((cookie.Contains("tracknick") || cookie.Contains("dnk") || cookie.Contains("_w_tb_nick"))) { BaseClass.IeFormCookies = ChromeCookies = cookie; BaseClass.x5Sec = BaseRegex.GetMatchRegexString(ref cookiesSrt, "\"name\": \"x5sec\",[\\s\\S]+?\"value\": \"([\\s\\S]+?)\""); if (string.IsNullOrEmpty(BaseClass.x5Sec)) BaseClass.x5Sec = BaseRegex.GetMatchRegexString(ref cookiesSrt, "x5sec=([\\s\\S]+?);"); } //if (cookie.Contains("x5sec")&&TitleText == "淘宝验证窗口" && isH5 && (cookie.Contains("tracknick") || cookie.Contains("dnk") || cookie.Contains("_w_tb_nick"))) // BaseClass.IeFormCookies = cookie; //if (string.IsNullOrEmpty(BaseClass.x5Sec)) //{ // BaseClass.x5Sec = BaseRegex.GetMatchRegexString(ref cookiesSrt, "\"name\": \"x5sec\",[\\s\\S]+?\"value\": \"([\\s\\S]+?)\""); // if (string.IsNullOrEmpty(BaseClass.x5Sec)) // BaseClass.x5Sec = BaseRegex.GetMatchRegexString(ref cookiesSrt, "x5sec=([\\s\\S]+?);"); //} } //if (TaobaoMobileCollect.CookiesDic.Count==0) //{ // GetLoginUserName(); //} //string x5Sec = BaseRegex.GetMatchRegexString(ref IeForm.ChromeCookies, @"x5sec=([\w\W]+?);"); //if (!string.IsNullOrEmpty(x5Sec) && x5Sec != oldSec) //{ // BaseClass.x5Sec = x5Sec; // oldSec = x5Sec; //} } } catch { } } public List cookies = new List(); /// /// 加载完成时,重设cookies /// /// private void visitor_SendCookie(CefSharp.Cookie obj) { cookies.Add(obj); } /// /// 获取cookies /// private void GetCookies() { cookies.Clear(); var cookieManager = cefWebBrowser3.RequestContext.GetCookieManager(null); CookieVisitor visitor = new CookieVisitor(); visitor.SendCookie += visitor_SendCookie; cookieManager.VisitAllCookies(visitor); } private void delCookiesButtonX_Click(object sender, EventArgs e) { string cboname = userComboBox.Text; Task.Run(() => { UserCookies.Remove(cboname); if (UserCookies.Count > 0) SetCookiesUserInfo.UserName = UserCookies.FirstOrDefault().Key; else SetCookiesUserInfo.UserName = ""; TaobaoMobileCollect.CookiesDic.Remove(cboname); DelCookies(); ChromeCookies = ""; ResetUserList(); SaveCookies(); SetTaoBao(SetCookiesUserInfo.UserName, true); LoginOk = false; cefWebBrowser3.Load("https://s.taobao.com/search?q=se"); }); } private void buttonEx1_Click(object sender, EventArgs e) { if (!string.IsNullOrEmpty(BaseClass.x5Sec)) { MessageBox.Show("获取滑动参数成功。"); return; } string cookies = string.Empty; IDataObject iData = Clipboard.GetDataObject(); if (iData.GetDataPresent(DataFormats.Text)) { cookies = (string)iData.GetData(DataFormats.Text); } if (string.IsNullOrEmpty(cookies)) { BaseClass.x5Sec = BaseRegex.GetMatchRegexString(ref cookiesSrt, "\"name\": \"x5sec\",[\\s\\S]+?\"value\": \"([\\s\\S]+?)\""); if (string.IsNullOrEmpty(BaseClass.x5Sec)) BaseClass.x5Sec = BaseRegex.GetMatchRegexString(ref cookiesSrt, "x5sec=([\\s\\S]+?);"); if (string.IsNullOrEmpty(BaseClass.x5Sec)) MessageBox.Show("获取滑动参数失败。"); else MessageBox.Show("获取滑动参数成功。"); return; } string x5Sec = BaseRegex.GetMatchRegexString(ref cookies, "\"name\": \"x5sec\",[\\s\\S]+?\"value\": \"([\\s\\S]+?)\""); if (string.IsNullOrEmpty(x5Sec)) { x5Sec = BaseRegex.GetMatchRegexString(ref cookies, "x5sec=([\\s\\S]+?);"); } if (string.IsNullOrEmpty(x5Sec)) { x5Sec = BaseRegex.GetMatchRegexString(ref cookiesSrt, "\"name\": \"x5sec\",[\\s\\S]+?\"value\": \"([\\s\\S]+?)\""); if (string.IsNullOrEmpty(x5Sec)) x5Sec = BaseRegex.GetMatchRegexString(ref cookiesSrt, "x5sec=([\\s\\S]+?);"); } if (string.IsNullOrEmpty(x5Sec)) { Thread.Sleep(2000); x5Sec = BaseRegex.GetMatchRegexString(ref IeForm.ChromeCookies, @"x5sec=([\w\W]+?);"); } BaseClass.x5Sec = x5Sec; if (string.IsNullOrEmpty(x5Sec)) { MessageBox.Show("获取滑动参数失败。"); return; } else { MessageBox.Show("获取滑动参数成功。"); return; } } public void AutoRrefreshCookies() { while (true) { try { Thread.Sleep(10 * 60 * 1000); var lst = UserCookies.ToList(); for (int i = 0; i < lst.Count; i++) { DelCookies(); SetTaoBao(lst[i].Key, true); LoginOk = false; cefWebBrowser3.Load("https://buyertrade.taobao.com/trade/itemlist/list_bought_items.htm"); Thread.Sleep(8 * 1000); } } catch { } } } private void buttonEx2_Click(object sender, EventArgs e) { new Thread(AutoRrefreshCookies).Start(); } private void buttonEx1_Click_1(object sender, EventArgs e) { if (!string.IsNullOrEmpty(BaseClass.x5Sec)) { MessageBox.Show("获取滑动参数成功。"); return; } string cookies = string.Empty; IDataObject iData = Clipboard.GetDataObject(); if (iData.GetDataPresent(DataFormats.Text)) { cookies = (string)iData.GetData(DataFormats.Text); } if (string.IsNullOrEmpty(cookies)) { BaseClass.x5Sec = BaseRegex.GetMatchRegexString(ref cookiesSrt, "\"name\": \"x5sec\",[\\s\\S]+?\"value\": \"([\\s\\S]+?)\""); if (string.IsNullOrEmpty(BaseClass.x5Sec)) BaseClass.x5Sec = BaseRegex.GetMatchRegexString(ref cookiesSrt, "x5sec=([\\s\\S]+?);"); if (string.IsNullOrEmpty(BaseClass.x5Sec)) MessageBox.Show("获取滑动参数失败。"); else MessageBox.Show("获取滑动参数成功。"); return; } string x5Sec = BaseRegex.GetMatchRegexString(ref cookies, "\"name\": \"x5sec\",[\\s\\S]+?\"value\": \"([\\s\\S]+?)\""); if (string.IsNullOrEmpty(x5Sec)) { x5Sec = BaseRegex.GetMatchRegexString(ref cookies, "x5sec=([\\s\\S]+?);"); } if (string.IsNullOrEmpty(x5Sec)) { x5Sec = BaseRegex.GetMatchRegexString(ref cookiesSrt, "\"name\": \"x5sec\",[\\s\\S]+?\"value\": \"([\\s\\S]+?)\""); if (string.IsNullOrEmpty(x5Sec)) x5Sec = BaseRegex.GetMatchRegexString(ref cookiesSrt, "x5sec=([\\s\\S]+?);"); } if (string.IsNullOrEmpty(x5Sec)) { Thread.Sleep(2000); x5Sec = BaseRegex.GetMatchRegexString(ref IeForm.ChromeCookies, @"x5sec=([\w\W]+?);"); } BaseClass.x5Sec = x5Sec; if (string.IsNullOrEmpty(x5Sec)) { MessageBox.Show("获取滑动参数失败。"); return; } else { MessageBox.Show("获取滑动参数成功。"); return; } } /// /// 本次软件运行期间是否不再显示淘宝登录/校验 /// public static bool IsShowIeForm = true; private void checkBox1_CheckedChanged(object sender, EventArgs e) { IsShowIeForm = !checkBox1.Checked; } } }