private void Init_tb_reg() { if (IsInit_tb_loaded) { return; } IsInit_tb_loaded = true; //填会员信息 Operation new_register = new Operation(MainCefFrame) { CurrentUrl = "http://reg.taobao.com/member/new_register.jhtml", index = 1, PerviousStatus = BusinessStatus.new_register, NextStatus = BusinessStatus.new_cellphone_reg_two, }; new_register.OperationHandler += (s, e) => { #region ==========填会员信息========== //获取ID=J_CheckCode 的data-imgurl属性的值url //识别url中的图片 new Thread(() => { string srcs = ""; for (int i = 0; i < 3; i++) { srcs = CefFrameHelper.GetUrlListByHapId(MainCefFrame, "J_CheckCode", "div", "data-imgurl").FirstOrDefault(); if (!string.IsNullOrEmpty(srcs)) { break; } } if (string.IsNullOrEmpty(srcs)) { LogManager.WriteLog("重复3次后仍然无法获取图片。"); return; } srcs = srcs.Replace("&", "&"); string returnMess; var isVCodeOk = Vcode.GetVcodeFormImageUrl(srcs, out returnMess); Console.WriteLine(isVCodeOk); // string js2run = "document.getElementById('J_Nick').value='{0}';".With(currentHaoZi.tbName) + "document.getElementById('J_Pwd').value='{0}';".With(currentHaoZi.tbPwd) + "document.getElementById('J_RePwd').value='{0}';".With(currentHaoZi.tbPwd) + "document.getElementById('J_Code').value='{0}';".With(returnMess) + "document.getElementById('J_BtnBasicInfoForm').click();"; CefFrameHelper.ExcuteJs(MainCefFrame, js2run); }).Start(); #endregion }; //验证账户信息-选择方式(手机或邮箱) Operation new_cellphone_reg_two = new Operation(MainCefFrame) { PerviousStatus = BusinessStatus.new_cellphone_reg_two, NextStatus = BusinessStatus.new_email_reg_two, CurrentUrl = "http://reg.taobao.com/member/new_cellphone_reg_two.jhtml", index = 2 }; new_cellphone_reg_two.OperationHandler += (s, e) => { // BeginInvoke(new Action(() => { FindTitleAndLoadHref("使用邮箱验证"); // })); }; //验证账户信息-选择方式(手机或邮箱)-输入邮箱手机打码 Operation new_email_reg_three = new Operation(MainCefFrame) { PerviousStatus = BusinessStatus.new_email_reg_two, NextStatus = BusinessStatus.new_email_reg_three, CurrentUrl = "http://reg.taobao.com/member/new_email_reg_two.jhtml", index = 3 }; new_email_reg_three.OperationHandler += (s, e) => { string js2runS1 = "document.getElementById('J_Email').value='{0}';".With(currentHaoZi.zfbEmail) + "document.getElementsByClassName('btn-b tsl')[0].click();"; CefFrameHelper.ExcuteJs(MainCefFrame, js2runS1); this.bfForms.BT_TB_ChangeTel_Click(s, e); }; //验证账户信息-选择方式(手机或邮箱)-获取激活链接 Operation register_confirm = new Operation(MainCefFrame) { PerviousStatus = BusinessStatus.new_email_reg_three, NextStatus = BusinessStatus.regitster_confirm, CurrentUrl = "http://reg.taobao.com/member/new_email_reg_three.jhtml", index = 4 }; register_confirm.OperationHandler += BT_FindActiveUrl_Click; //验证用户信息-完成 Operation account_management = new Operation(MainCefFrame) { PerviousStatus = BusinessStatus.regitster_confirm, NextStatus = BusinessStatus.account_management, CurrentUrl = "http://reg.taobao.com/member/register_confirm.jhtml", //https://lab.alipay.com/user/reg/complete/completeTaobao.htm index = 5 }; account_management.OperationHandler += (s, e) => { MainCefFrame.LoadUrl("http://member1.taobao.com/member/fresh/account_management.htm"); }; Operation completeTaobao = new Operation(MainCefFrame) { PerviousStatus = BusinessStatus.account_management, NextStatus = BusinessStatus.paymethod, CurrentUrl = "http://member1.taobao.com/member/fresh/account_management.htm", index = 6 }; completeTaobao.OperationHandler += (s, e) => { FindTitleAndLoadHref("立即补全"); }; Operation paymethod = new Operation(MainCefFrame) { PerviousStatus = BusinessStatus.paymethod, NextStatus = BusinessStatus.zfb_Reg_paymethod, index = 7, CurrentUrl = "https://memberprod.alipay.com/account/reg/complete/complete.htm?scene=havanaComplete" }; paymethod.OperationHandler += BT_TB_FILLZFB_Click; //===================支付宝注册流程 Operation Zfb_Fill_Account = new Operation(MainCefFrame) { PerviousStatus = BusinessStatus.zfb_reg_begin, NextStatus = BusinessStatus.emailCheck, CurrentUrl = GlobalVar.zfb_Reg_enter_1, index = 1, Deadline = 1000 * 60 * 5 }; Zfb_Fill_Account.OperationHandler += BT_Zfb_Fill_Account_Click; Operation emailCheck = new Operation(MainCefFrame) { PerviousStatus = BusinessStatus.emailCheck, NextStatus = BusinessStatus.zfb_reg_link_complete, CurrentUrl = "https://memberprod.alipay.com/account/reg/emailCheck.htm", index = 1.1 }; emailCheck.OperationHandler += (s, e) => { BT_Zfb_Reg_Sumbit_s1_Click(this, new EventArgs()); }; Operation zfb_reg_link_complete = new Operation(MainCefFrame) { PerviousStatus = BusinessStatus.zfb_reg_link_complete, NextStatus = BusinessStatus.zfb_Reg_paymethod, CurrentUrl = GlobalVar.zfb_Reg_linkcomplete, index = 2 }; zfb_reg_link_complete.OperationHandler += BT_Zfb_reg_fill_Click; Operation zfb_Reg_paymethod = new Operation(MainCefFrame) { PerviousStatus = BusinessStatus.zfb_Reg_paymethod, NextStatus = BusinessStatus.zfb_reg_account_reg_success, CurrentUrl = GlobalVar.zfb_Reg_paymethod, index = 3 }; zfb_Reg_paymethod.OperationHandler += BT_ZFB_TB_Reg_Click; Operation zfb_reg_account_reg_success = new Operation(MainCefFrame) { PerviousStatus = BusinessStatus.zfb_reg_account_reg_success, NextStatus = BusinessStatus.zfb_reg_account_reg_success, CurrentUrl = GlobalVar.zfb_reg_account_reg_success, index = 4, note = " 导航至添加密保,跳到 开通淘宝" }; //zfb_reg_account_reg_success.OperationHandler += BT_ZFB_REG_nav2addsq_Click; // BT_ZFB_REG_Account_Sucess_Click zfb_reg_account_reg_success.OperationHandler += BT_ZFB_REG_Account_Sucess_Click; Operation zfb_reg_skip_bindassetcard = new Operation(MainCefFrame) { PerviousStatus = BusinessStatus.zfb_reg_account_reg_success, //NextStatus = BusinessStatus.zfb_reg_taobao_open,//换 NextStatus = BusinessStatus.zfb_reg_nav2set_add_SecurityQuestion_before, CurrentUrl = GlobalVar.zfb_reg_skip_bindassetcard, index = 5 }; zfb_reg_skip_bindassetcard.OperationHandler += BT_ZFB_REG_TB_open_Click; Operation zfb_reg_taobao_new_alipay_q = new Operation(MainCefFrame) { PerviousStatus = BusinessStatus.zfb_reg_taobao_new_alipay_q, NextStatus = BusinessStatus.nav2deliver_address, CurrentUrl = GlobalVar.zfb_reg_taobao_new_alipay_q, index = 31, note = "开通tb", Deadline = int.Parse(ConfigHelper.GetValue("zfb_reg_taobao_new_alipay_RegDeadline")) * 60 * 1000 }; zfb_reg_taobao_new_alipay_q.OperationHandler += BT_ZFB_REG_TB_new_alipay_q_Click; Operation nav2deliver_address = new Operation(MainCefFrame) { PerviousStatus = BusinessStatus.nav2deliver_address, NextStatus = BusinessStatus.deliver_address, CurrentUrl = "http://reg.taobao.com/member/register_confirm.jhtml", index = 32, note = "注册完成-跳转->添加收货地址的页面" }; nav2deliver_address.OperationHandler += (s, e) => { MainCefFrame.LoadUrl( "http://member1.taobao.com/member/fresh/deliver_address.htm"); }; Operation add_deliver_address = new Operation(MainCefFrame) { PerviousStatus = BusinessStatus.deliver_address, NextStatus = BusinessStatus.ready, CurrentUrl = "http://member1.taobao.com/member/fresh/deliver_address.htm", index = 33, note = "添加收货地址", }; add_deliver_address.Deadline = GlobalVar.DeadLineOfChangeClearAndPrepareNext; add_deliver_address.OperationHandler += (s, e) => { var js2run = RandomAddressPlace(); CefFrameHelper.ExcuteJs(MainCefFrame, js2run); new Thread(() => { currentHaoZi.regStatus = DateTime.Now.ToString(); currentHaoZi.tbStatus = GlobalVar.CurrentIp; HaoziHelper.UpdateLoadHaozi(ConfigHelper.GetValue("WebSite"), currentHaoZi, "add"); // Thread.Sleep(6000); LogManager.WriteLog("开始下一个"); ClearAndPrepareNext(); }).Start(); }; this.opsList.Add(Zfb_Fill_Account); this.opsList.Add(emailCheck); this.opsList.Add(zfb_reg_link_complete); this.opsList.Add(zfb_Reg_paymethod); this.opsList.Add(zfb_reg_account_reg_success); this.opsList.Add(zfb_reg_skip_bindassetcard); this.opsList.Add(zfb_reg_taobao_new_alipay_q); this.opsList.Add(nav2deliver_address); this.opsList.Add(add_deliver_address); this.opsList.Add(new_register); this.opsList.Add(new_cellphone_reg_two); this.opsList.Add(new_email_reg_three); this.opsList.Add(register_confirm); this.opsList.Add(account_management); this.opsList.Add(completeTaobao); this.opsList.Add(paymethod); }
private void tbV3_Init_reg() { if (IsInit_tbV3_loaded) { return; } IsInit_tbV3_loaded = true; Operation fill_mobile = new Operation(MainCefFrame) { CurrentUrl = "http://reg.taobao.com/member/reg/fill_mobile.htm", index = 1.1, PerviousStatus = BusinessStatus.Tb_reg_v3_member_reg_fill_mobile_before, NextStatus = BusinessStatus.Tb_reg_v3_member_reg_fill_mobile, }; fill_mobile.OperationHandler += (s, e) => { string js2run = "document.getElementsByClassName('f12')[1].getElementsByTagName('a')[0].click()"; CefFrameHelper.ExcuteJs(MainCefFrame, js2run); }; //填会员信息 Operation new_register = new Operation(MainCefFrame) { CurrentUrl = "http://reg.taobao.com/member/reg/fill_email.htm", index = 1.2, PerviousStatus = BusinessStatus.Tb_reg_v3_member_reg_fill_mobile, NextStatus = BusinessStatus.Tb_reg_v3_member_reg_fill_email, Deadline = ConfigHelper.GetIntValue("TBV3注册第一步耗时") * 1000 * 60, }; new_register.OperationHandler += (s, e) => { #region ==========填会员信息&过手机验证========== //获取ID=J_CheckCode 的data-imgurl属性的值url //识别url中的图片 string js3run = "document.getElementById('J_CheckCodeInput').focus();"; CefFrameHelper.ExcuteJs(MainCefFrame, js3run); new Thread(() => { Thread.Sleep(ConfigHelper.GetIntValue("等待验证码时间(秒)") * 1000); var isVCodeOk = false; for (int j = 0; !isVCodeOk && j < 3; j++) { bool vcodeFrom51 = false; string srcs = ""; for (int i = 0; i < 3; i++) { //srcs = CefFrameHelper.GetUrlListByHapId(MainCefFrame, "J_CheckCodeContainer", "div", "data-imgurl").FirstOrDefault(); srcs = CefFrameHelper.GetUrlListByHapId(MainCefFrame, "J_CheckCodeImg1", "img", "src").FirstOrDefault(); srcs = srcs.Replace("&", "&"); if (!string.IsNullOrEmpty(srcs)) { break; } } if (string.IsNullOrEmpty(srcs)) { LogManager.WriteLog("重复3次后仍然无法获取图片。"); return; } string returnMess; vcodeFrom51 = Vcode.GetVcodeFormImageUrl(srcs, out returnMess); if (!vcodeFrom51) { continue; } string js2run = "document.getElementById('J_Email').value='{0}';".With(currentHaoZi.zfbEmail) + "document.getElementById('J_CheckCodeInput').value='{0}';".With(returnMess) + "document.getElementById('J_BtnEmailForm').click();"; CefFrameHelper.ExcuteJs(MainCefFrame, js2run); #region ==================过验证码==================== new Thread(() => { Thread.Sleep(3000); var res = ""; for (int i = 0; i < 3; i++) { res = CefFrameHelper.GetMsgByJs(MainCefFrame, "document.getElementById('J_MobileCheck').getAttribute('style')"); if (!string.IsNullOrEmpty(res)) { break; } Thread.Sleep(1000); } if (res.Contains("block")) { isVCodeOk = true; } checkVcodeOkEvent.Set(); }).Start(); checkVcodeOkEvent.Reset(); checkVcodeOkEvent.WaitOne(9000); #endregion if (isVCodeOk) { break; } } //手机验证 new Thread(() => { try { phoneVailed(state); } catch (Exception e2) { LogManager.WriteLog(e2.StackTrace + e2.ToString()); } }).Start(); // }).Start(); #endregion }; //账户注册-1.设置登录名-接收邮件 Operation email_sent = new Operation(MainCefFrame) { PerviousStatus = BusinessStatus.Tb_reg_v3_member_reg_fill_email, NextStatus = BusinessStatus.Tb_reg_v3_member_reg_email_sent, CurrentUrl = "http://reg.taobao.com/member/reg/email_sent.htm", index = 2, note = "账户注册-1.设置登录名-接收邮件" }; email_sent.OperationHandler += (s, e) => { // BeginInvoke(new Action(() => { Thread.Sleep(5000); var url = EmailCheck("新用户确认通知信", "request_dispatcher.htm"); MainCefFrame.LoadUrl(url); // })); }; Operation fill_user_info = new Operation(MainCefFrame) { PerviousStatus = BusinessStatus.Tb_reg_v3_member_reg_email_sent, NextStatus = BusinessStatus.Tb_reg_v3_Member_reg_fill_user_info, CurrentUrl = "http://reg.taobao.com/member/reg/fill_user_info.htm", index = 3, note = "账户注册-2.填写账户信息" }; fill_user_info.OperationHandler += (s, e) => { string js2runS1 = "document.getElementById('J_Password').value='{0}';".With(currentHaoZi.tbPwd) + "document.getElementById('J_RePassword').value='{0}';".With(currentHaoZi.tbPwd) + "document.getElementById('J_Nick').value='{0}';".With(currentHaoZi.tbName) + "document.getElementById('J_BtnInfoForm').click();"; CefFrameHelper.ExcuteJs(MainCefFrame, js2runS1); }; Operation login_unusual = new Operation(MainCefFrame) { PerviousStatus = BusinessStatus.Tb_reg_v3_Member_reg_fill_user_info, NextStatus = BusinessStatus.Tb_reg_v3_member_reg_reg_success, CurrentUrl = "http://login.taobao.com/member/login_unusual.htm", //http://login.taobao.com/member/login_unusual.htm index = 4.1, note = "登录身份验证 ", }; login_unusual.OperationHandler += (s, e) => { toolStripMenuItem20_Click(this, new EventArgs());//过登录验证 }; Operation member_reg_reg_success = new Operation(MainCefFrame) { PerviousStatus = BusinessStatus.Tb_reg_v3_Member_reg_fill_user_info, NextStatus = BusinessStatus.Tb_reg_v3_member_reg_reg_success, CurrentUrl = "http://reg.taobao.com/member/reg/reg_success.htm", index = 4.2, note = "淘宝注册成功 填写收货地址", }; member_reg_reg_success.OperationHandler += (s, e) => { //var url = "http://member1.taobao.com/member/fresh/account_management.htm"; var url = "http://member1.taobao.com/member/fresh/deliver_address.htm"; MainCefFrame.LoadUrl(url); }; Operation deliver_address = new Operation(MainCefFrame) { PerviousStatus = BusinessStatus.Tb_reg_v3_member_reg_reg_success, NextStatus = BusinessStatus.Tb_reg_v3_deliver_address, CurrentUrl = "http://member1.taobao.com/member/fresh/deliver_address.htm", index = 33, note = "添加收货地址 判断是否激活支付宝 ", }; deliver_address.OperationHandler += (s, e) => { var js2run = RandomAddressPlace(); CefFrameHelper.ExcuteJs(MainCefFrame, js2run); new Thread(() => { Application.DoEvents(); Thread.Sleep(3000); bool activeZFB = ConfigHelper.GetBoolValue("是否激活支付宝"); if (activeZFB) { var url = "http://member1.taobao.com/member/fresh/account_management.htm"; MainCefFrame.LoadUrl(url); } else { FinishOneResgister(); } }).Start(); }; Operation member_fresh_account_management = new Operation(MainCefFrame) { PerviousStatus = BusinessStatus.Tb_reg_v3_deliver_address, NextStatus = BusinessStatus.Tb_reg_v3_member_fresh_account_management, CurrentUrl = "http://member1.taobao.com/member/fresh/account_management.htm", index = 5, note = "找到 包含 立即补全 的链接 前往" }; member_fresh_account_management.OperationHandler += (s, e) => { string js2runS1 = "document.getElementsByClassName('kv_item')[2].getElementsByTagName('a')[0].click();"; CefFrameHelper.ExcuteJs(MainCefFrame, js2runS1); }; Operation account_reg_complete_complete = new Operation(MainCefFrame) { PerviousStatus = BusinessStatus.Tb_reg_v3_member_fresh_account_management, NextStatus = BusinessStatus.Tb_reg_v3_account_reg_complete_complete, CurrentUrl = "https://memberprod.alipay.com/account/reg/complete/complete.htm", index = 6, note = "开通支付宝 填支付密码" }; account_reg_complete_complete.OperationHandler += (s, e) => { string js2runS1 = " document.getElementById('queryPwd').value='{0}';".With(currentHaoZi.zfbPwd) + "document.getElementById('queryPwdConfirm').value='{0}';".With(currentHaoZi.zfbPwd) + "document.getElementById('payPwd').value='{0}';".With(currentHaoZi.zfbPayPwd) + "document.getElementById('payPwdConfirm').value='{0}';".With(currentHaoZi.zfbPayPwd) + "document.getElementById('realName').value='{0}';".With(currentHaoZi.realname) + "document.getElementById('IDCardNo').value='{0}';".With(currentHaoZi.zfbSFZ) + "document.getElementById('J-complete-form').submit();"; CefFrameHelper.ExcuteJs(MainCefFrame, js2runS1); }; Operation asset_paymethod_paymethod = new Operation(MainCefFrame) { PerviousStatus = BusinessStatus.Tb_reg_v3_account_reg_complete_complete, NextStatus = BusinessStatus.Tb_reg_v3_asset_paymethod_paymethod, CurrentUrl = "https://zht.alipay.com/asset/paymethod/paymethod.htm", index = 7 }; asset_paymethod_paymethod.OperationHandler += (s, e) => { MainCefFrame.LoadUrl("https://benefitprod.alipay.com/asset/paymethod/bindassetcard.htm"); }; Operation account_reg_success = new Operation(MainCefFrame) { PerviousStatus = BusinessStatus.Tb_reg_v3_asset_paymethod_paymethod, NextStatus = BusinessStatus.Tb_reg_v3_account_reg_success, CurrentUrl = "https://memberprod.alipay.com/account/reg/success.htm", index = 8, note = "开通支付宝成功" }; account_reg_success.OperationHandler += (s, e) => { // new Thread(() => { FinishOneResgister(); // }).Start(); }; this.opsList.Add(fill_mobile); this.opsList.Add(new_register); this.opsList.Add(email_sent); this.opsList.Add(login_unusual); this.opsList.Add(fill_user_info); this.opsList.Add(member_reg_reg_success); this.opsList.Add(deliver_address); this.opsList.Add(member_fresh_account_management); this.opsList.Add(account_reg_complete_complete); this.opsList.Add(asset_paymethod_paymethod); this.opsList.Add(account_reg_success); }
private void IsInit_wapshop() { if (IsInit_wapshop_loaded) { return; } Operation mtb = new Operation(MainCefFrame) { PerviousStatus = BusinessStatus.mtb, NextStatus = BusinessStatus.gerenzhongxin, CurrentUrl = "login.m.taobao.com/login.htm", index = 1, note = "登录" }; mtb.OperationHandler += (s, e) => { // if (GlobalVar.tbmode == tbModel.shopv2) { //window.onload=function(){if(window.frames.length!=0){window.location.reload();}} //ReflushIfInFrames(); // } taskRunner.LogAccontStatus("|{0}".With(MouseKeyBordHelper.CurrentIP));// #region ==========识别验证码========== //1.识别验证码 string srcs = ""; for (int i = 0; i < 3; i++) { // //Img Id=J_StandardCode data-url srcs = CefFrameHelper.GetUrlListByHapId(MainCefFrame, "J_StandardCode", "img", "data-url").FirstOrDefault(); if (!string.IsNullOrEmpty(srcs)) { break; } } if (string.IsNullOrEmpty(srcs)) { LogManager.WriteLog("重复3次后仍然无法获取图片。"); return; } string returnMess; var isVCodeOk = Vcode.GetVcodeFormImageUrl(srcs, out returnMess); //2.提交验证码 string js2run = beforejs + " mydoc.getElementById('J_UserNameTxt').value='{0}';".With(currentHaoZi.tbName) + "mydoc.getElementById('J_PassWordTxt').value='{0}';".With(currentHaoZi.tbPwd) + "mydoc.getElementById('J_AuthCodeTxt').value='{0}';".With(returnMess) + "mydoc.getElementsByClassName('c-btn-oran-big')[0].click();"; if (isVCodeOk) { // LogManager.WriteLog(js2run); CefFrameHelper.ExcuteJs(MainCefFrame, js2run); } else { LogManager.WriteLog("验证码识别出错。等待2分钟后重新执行"); } new Thread(() => { Thread.Sleep(3000); if (isCurrentPage(s as Operation)) { LogManager.WriteLog("还在当前页"); string warnmsg = CefFrameHelper.ExtractWarnMsg(MainCefFrame).Trim(); if (warnmsg == "该账户名不存在") { taskRunner.ReportAccountStatus("buy", "failed", warnmsg); ClearAndPrepareNext(); } ; } }).Start(); #endregion }; // Operation mtbloginEx = new Operation(MainCefFrame) { PerviousStatus = BusinessStatus.gerenzhongxin, NextStatus = BusinessStatus.wapshop_ex_loginerror, CurrentUrl = "login.m.taobao.com/login.htm?_input_charset=utf-8&sid=", index = 2, note = "登录失败" }; mtbloginEx.OperationHandler += (s, e) => { taskRunner.ReportAccount("failed"); ClearAndPrepareNext(); }; //进入搜索页 //直接跳转 //Operation gerenzhongxin = new Operation(MainCefFrame) { // PerviousStatus = BusinessStatus.gerenzhongxin, // NextStatus = BusinessStatus.Awp_core_detail, // CurrentUrl = "http://h5.m.taobao.com/awp/mtb/mtb.htm", // index = 2, // note = "跳转到某货" //}; //gerenzhongxin.OperationHandler += (s, e) => { // string shaopaddress = FileHelper.RandomReadOneLine("config//goodaddress.txt");// "http://h5.m.taobao.com/awp/core/detail.htm?id=39552254784&spm=0.0.0.0"; // MainCefFrame.LoadUrl(shaopaddress); //}; //跳转到搜索 Operation act_sale_searchlist = new Operation(MainCefFrame) { PerviousStatus = BusinessStatus.gerenzhongxin, NextStatus = BusinessStatus.act_sale_searchlist, CurrentUrl = "h5.m.taobao.com/awp/mtb/mtb.htm", index = 2.1, note = "跳转到搜索页面" }; act_sale_searchlist.OperationHandler += (s, e) => { string js2run = beforejs + "window.location=mydoc.getElementsByClassName('search')[0].getElementsByTagName('a')[0].getAttribute('dataurl');"; CefFrameHelper.ExcuteJs(MainCefFrame, js2run); }; //输入关键字 Operation search_htm = new Operation(MainCefFrame) { PerviousStatus = BusinessStatus.act_sale_searchlist, NextStatus = BusinessStatus.search_htm, CurrentUrl = "m.taobao.com/channel/act/sale/searchlist.html?pds=search", index = 2.21, note = "输入搜索的关键字" }; search_htm.OperationHandler += SearchOneItem; //输入关键字2 Operation search_htm2 = new Operation(MainCefFrame) { PerviousStatus = BusinessStatus.act_sale_searchlist, NextStatus = BusinessStatus.search_htm, CurrentUrl = "m.taobao.com/?from=wapp", index = 2.22, note = "输入搜索的关键字" }; search_htm2.OperationHandler += SearchOneItem; //跳转到随机一个搜索结果`1 Operation search_htm2detail = new Operation(MainCefFrame) { PerviousStatus = BusinessStatus.search_htm, NextStatus = BusinessStatus.Awp_core_detail, index = 2.31, CurrentUrl = "s.m.taobao.com/h5?q=", note = "跳转到随机一个搜索结果" }; search_htm2detail.OperationHandler += ChooseOneItem; //跳转到随机一个搜索结果`2 Operation search_htm2detail2 = new Operation(MainCefFrame) { PerviousStatus = BusinessStatus.search_htm, NextStatus = BusinessStatus.Awp_core_detail, index = 2.32, CurrentUrl = "s.m.taobao.com/search.htm?q=", note = "跳转到随机一个搜索结果" }; search_htm2detail2.OperationHandler += ChooseOneItem; //end of 2 Operation Awp_core_detail = new Operation(MainCefFrame) { PerviousStatus = BusinessStatus.Awp_core_detail, NextStatus = BusinessStatus.awp_base_buy, CurrentUrl = "h5.m.taobao.com/awp/core/detail.htm?id=", index = 3, note = "确认下单" }; Awp_core_detail.OperationHandler += (s, e) => { int sleepTime = RandomManager.random.Next(2, 8); LogManager.WriteLog("暂停{0}秒".With(sleepTime)); Thread.Sleep(sleepTime * 1000); string js2run = beforejs; //随机收藏 if (RandomManager.randomBool()) { js2run += "mydoc.getElementsByClassName('dts-fav')[0].click();"; } js2run += "window.setTimeout(function(){mydoc.getElementsByClassName('c-btn-orgn dt-immbuy')[0].click();},2000); "; CefFrameHelper.ExcuteJs(MainCefFrame, js2run); ExtractIfCurrentPage(s); }; Operation awp_base_buy = new Operation(MainCefFrame) { PerviousStatus = BusinessStatus.awp_base_buy, NextStatus = BusinessStatus.exCashier, CurrentUrl = "h5.m.taobao.com/awp/base/buy.htm?itemId=", index = 4, note = "提交订单" }; awp_base_buy.OperationHandler += (s, e) => { var str = RandomManager.RandomReadOneLine("import//liuyan.txt"); str = str.ReplaceNum(); //返回的随机数的下界(随机数可取该下界值)。返回的随机数的上界(随机数不能取该上界值)。 bool annoymous = RandomManager.random.Next(1, 3) > 1; ; bool isCurrentPage = false; for (int i = 0; i < 3; i++) { LogManager.WriteLog("#第{0}次购买".With(i)); // string js2run = beforejs + "mydoc.getElementsByClassName('c-form-txt-normal')[1].value='{0}';".With(str); if (annoymous) { js2run += "mydoc.getElementsByName('anonymous')[0].checked=true;"; } js2run += "mydoc.getElementsByClassName('submit-only c-btn-oran')[0].click();"; CefFrameHelper.ExcuteJs(MainCefFrame, js2run); // // new Thread(() => { Thread.Sleep(3000); lock (wap_tmp) { //if (!isCurrentPage(s as Operation)) { isCurrentPage = ExtractAndReloadIfCurrentPage(s); // //不停留在当前页面,则表示没问题 //} else { // LogManager.WriteLog("刷新并等待4秒"); // MainCefFrame.Browser.Reload(); // Thread.Sleep(4000); //} } if (!isCurrentPage) { break; } // }).Start(); } }; Operation exCashier = new Operation(MainCefFrame) { PerviousStatus = BusinessStatus.exCashier, NextStatus = BusinessStatus.asyn_payment_result, CurrentUrl = "wapcashier.alipay.com/cashier/exCashier.htm?orderId=", index = 4, note = "付款方式1" }; exCashier.OperationHandler += (s, e) => { //检查 //<span class="price">0.01元</span> float maxPrice; bool isOverPrice; var priceFloat = PriceFloat(out maxPrice, out isOverPrice); if (isOverPrice) { LogManager.WriteLog("{0}超出maxPrice:{1},停止购买".With(priceFloat, maxPrice)); return; } // //付款 string js2run = beforejs + "mydoc.getElementById('couponPayment').checked=true;" + "mydoc.getElementsByName('paymentPassword')[0].value='{0}';".With(currentHaoZi.zfbPayPwd) + "mydoc.getElementsByClassName('ui-button ui-button-submit')[0].click();"; CefFrameHelper.ExcuteJs(MainCefFrame, js2run); ExtractIfCurrentPage(s); }; Operation exCashier2 = new Operation(MainCefFrame) { PerviousStatus = BusinessStatus.exCashier, NextStatus = BusinessStatus.asyn_payment_result, CurrentUrl = "mclient.alipay.com/w/trade_pay.do?alipay_trade_no=", index = 5, note = "付款方式2" }; exCashier2.OperationHandler += (s, e) => { string js2run = beforejs + "mydoc.getElementById('pwd').value='{0}';".With(currentHaoZi.zfbPayPwd) + "mydoc.getElementsByClassName('J-button-submit')[0].click()"; CefFrameHelper.ExcuteJs(MainCefFrame, js2run); ExtractIfCurrentPage(s); }; #region ==========该次购买结束1、2========== Operation payok = new Operation(MainCefFrame) { PerviousStatus = BusinessStatus.asyn_payment_result, NextStatus = BusinessStatus.TB_shop_V2_Ready, CurrentUrl = "wapcashier.alipay.com/cashier/asyn_payment_result.htm", index = 6.1, note = "该次购买结束1", }; payok.OperationHandler += finishOneShop; Operation cashierPay = new Operation(MainCefFrame) { PerviousStatus = BusinessStatus.asyn_payment_result, NextStatus = BusinessStatus.TB_shop_V2_Ready, CurrentUrl = "mclient.alipay.com/cashierPay.htm?awid=", index = 6.2, note = "该次购买结束2", }; cashierPay.OperationHandler += finishOneShop; //购买失败 Operation accessDenied = new Operation(MainCefFrame) { PerviousStatus = BusinessStatus.asyn_payment_result, NextStatus = BusinessStatus.ready, CurrentUrl = "mclient.alipay.com/accessDenied.htm", index = 6.3, note = "无权访问,重试pay" }; accessDenied.OperationHandler += (s, e) => { lock (lockobject) { MainCefFrame.Browser.GoBack(); Thread.Sleep(3000); state = BusinessStatus.exCashier; MainCefFrame.Browser.Reload(); } }; // mclient.alipay.com/accessDenied.htm #endregion opsList.Add(mtb); // opsList.Add(gerenzhongxin); //搜索进店 opsList.Add(act_sale_searchlist); opsList.Add(search_htm); opsList.Add(search_htm2detail); opsList.Add(search_htm2detail2); //end of 搜索进店 opsList.Add(Awp_core_detail); opsList.Add(awp_base_buy); opsList.Add(exCashier); opsList.Add(exCashier2); // opsList.Add(payok); //成功方式一 opsList.Add(cashierPay); //成功方式二 opsList.Add(accessDenied); // opsList.Add(mtbloginEx); }
//淘宝V2 更换手机号码 //1.登录手机 //2.获取可用手机() // 2.1 获取手机 //3.获取可用短信 public void BT_TB_ChangeTel_Click(object sender, EventArgs e) { //1.登录手机 SmsConfigHelper.GetConfigOfSms(); if (!SmsApi.logined) { LBS_sms.Text = "登录失败"; return; } string phone = ""; Application.DoEvents(); lock (changeTel) { bool getPhoneOK = false; bool isVcodeOk = false; new Thread(() => { Thread.Sleep(2000); // bool isTelOK = false; for (int i = 0; i < 7; i++) { //2.1 检测是否当前已经通过手机验证 if (MainForm.state == BusinessStatus.regitster_confirm) { LogManager.WriteLog("当前不是获取手机号码{0}的页面了.".With(phone)); MainForm.state = BusinessStatus.new_email_reg_two; _mfForm.MainCefFrame.Browser.GoBack(); getPhoneOK = true; break; } //2.2 获取手机 phone = EnterPhone(); //2.3 检测手机是否可用 LogManager.WriteLog("check valueOfStyle"); string valueOfStyle = ""; bool is_valueOfStyle_ok = false; for (int j = 0; j < 3; j++) { valueOfStyle = CefFrameHelper.GetUrlListByHapId(MainCefFrame, "J_PhoneFormTip", "div", "style").FirstOrDefault(); LogManager.WriteLog("valueOfStyle:" + valueOfStyle); is_valueOfStyle_ok = valueOfStyle != null && valueOfStyle.Contains("hidden"); if (is_valueOfStyle_ok) { break; } else { Application.DoEvents(); Thread.Sleep(2000); } } if (valueOfStyle != null && valueOfStyle.Contains("hidden")) { //可用 LogManager.WriteLog("手机号码 {0} 可用.".With(phone)); isVcodeOk = UseThisPhoneNum(phone); if (isVcodeOk) { break; } else { //未获取到验证码的处理 TB_SMS_MSG.Text = "没有收到验证码,返回重新接收"; LogManager.WriteLog(TB_SMS_MSG.Text); // new Thread(() => { //页面上点击 返回修改手机号码 string js2run = "document.getElementById('J_RewritePhone').click()';"; CefFrameHelper.ExcuteJs(_mfForm.MainCefFrame, js2run); } } else { LogManager.WriteLog("手机号码 {1} 不可用.重新获取,{0}".With(5 - i, phone)); //释放单个手机 SmsApi.ReleasePhone(phone, "2"); } } if (!getPhoneOK || !isVcodeOk) { _mfForm.ShowStatus("获取手机失败,重新获取,或者自己去网站获取。"); } }).Start(); } // BT_ZFB_REG_TB_SMS_ENTERVCODE_Click(sender, e); }
public void BT_Zfb_Fill_Account_Click(object sender, EventArgs e) { // state = BusinessStatus.zfb_reg_link_complete; Operation operation = sender as Operation; if (operation != null) { if (!MainCefFrame.Url.Contains(GlobalVar.zfb_Reg_enter_1)) { LogManager.WriteLog("已经不是当前页了"); return; } } for (int i = 0; i < 7; i++) { //利用hpk获取到url string srcs = ""; for (int g = 0; g < 3; g++) { srcs = CefFrameHelper.GetUrlListByHapId(MainCefFrame, "J-checkcode-img", "img", "src").FirstOrDefault(); if (!string.IsNullOrEmpty(srcs)) { break; } Application.DoEvents(); Thread.Sleep(2000); } if (string.IsNullOrEmpty(srcs)) { LogManager.WriteLog("重复3次后仍然无法获取图片的链接。"); return; } //2获取验证码 string vcode; bool isVCodeOk = Vcode.GetVcodeFormImageUrl(srcs, out vcode); LogManager.WriteLog("{0} {1} ".With(isVCodeOk, vcode)); //3 提交验证码 if (isVCodeOk) { string js2run = " document.getElementById('J-accName').value = '{0}';".With(currentHaoZi.zfbEmail) + " document.getElementById('J-checkcode').value = '{0}';".With(vcode) + "document.getElementById('J-index-form').submit();" + "document.getElementsByClassName('ui-button-text')[0].click();"; CefFrameHelper.ExcuteJs(MainCefFrame, js2run); } else { LogManager.WriteLog("请手动刷新并输入验证码,再提交。"); } //4 检查验证码是否正确 //2 检测 是否可用 //LogManager.WriteLog("check checkcodeIcon"); //string valueOfStyle = ""; //bool is_valueOfStyle_ok = false; //for (int j = 0; j < 3; j++) { // valueOfStyle = // CefFrameHelper.GetUrlListByHapId(MainCefFrame, "checkcodeIcon", "span", "class") // .FirstOrDefault(); // LogManager.WriteLog("checkcodeIcon:" + valueOfStyle); // is_valueOfStyle_ok = !(valueOfStyle == null || valueOfStyle.Contains("checkcodeIcon-wrong")); // if (is_valueOfStyle_ok) { // break; // } // Application.DoEvents(); // Thread.Sleep(2000); //} //if (!is_valueOfStyle_ok) { // continue; //} //手机过验证码 mobilephoeOfzfb(); //收取邮件 //BT_Zfb_Reg_Sumbit_s1_Click(vcode, new EventArgs()); break; } }