private void waitforIp(string ip) { bool retry = true; do { HttpItems items = new HttpItems(); items.URL = @"http://www.ip138.com/ips1388.asp"; //items.ProxyIp = ip; items.Cookie = " "; //items.ProxyIp = ""; items.Timeout = 3000; HttpResults hr = new HttpHelpers().GetHtml(items); //string s = hr.StatusDescription; string reHtml = hr.Html.Replace("\r\n", "").Replace("\t", "").Replace("\n", "").Replace(" ", ""); if (reHtml.Contains("您的IP地址是")) { retry = false; reHtml = new XJHTTP().GetStringMid(reHtml, "您的IP地址是:[", "]"); //reHtml = new XJHTTP().GetStringMid(reHtml, "[", ""); } else { Tsleep(10); } }while (retry); }
public static List <GroupInfo> GetGroupList2(ICoolQApi api) { List <GroupInfo> list = new List <GroupInfo>(); try { //CQLogger.GetInstance().AddLog(string.Format("[↓][帐号] 取群列表", new object[0])); string url = "http://qun.qq.com/cgi-bin/qun_mgr/get_group_list"; var postData = new Dictionary <string, string>(); XJHTTP xJHTTP = new XJHTTP(); CookieContainer cookieContainer = xJHTTP.StringToCookie("qun.qq.com", api.GetCookies()); postData.Add("bkn", api.GetCsrfToken().ToString()); HttpResults httpResults = xJHTTP.PostHtml(url, "http://qun.qq.com/member.html", "bkn=" + api.GetCsrfToken().ToString(), false, cookieContainer, 15000); string sourceString = httpResults.Html; MyLogUtil.ToLog(httpResults.Html); var strReg = "{\"gc\":([1-9][0-9]{4,10}),\"gn\":\"(.*?)\",\"owner\":([1-9][0-9]{4,10})}"; Regex reg = new Regex(strReg); MatchCollection matches = reg.Matches(sourceString); MyJsonUtil <GroupInfo2> myJsonUtil = new MyJsonUtil <GroupInfo2>(); foreach (Match match in matches) { GroupInfo2 g = myJsonUtil.parseJsonStr(match.Value); list.Add(new GroupInfo(g.gn, g.gc, g.owner)); } } catch (Exception ex) { //MessageBox.Show(ex.Message); MyLogUtil.ErrToLog("获取群列表出现错误,原因:" + ex); } return(list); }
/// <summary> /// Post /// </summary> /// <param name="Url"></param> /// <param name="Postdata"></param> /// <param name="Cookie"></param> /// <param name="ProxyIp"></param> /// <param name="ContentType"></param> /// <param name="Referer"></param> /// <returns></returns> public static HttpResults Nut_Post(String Url, String Postdata, String Cookie, String ProxyIp, String Referer = null, String ContentType = "application/x-www-form-urlencoded") { HttpHelpers helper = new HttpHelpers(); //请求执行对象 HttpItems items; //请求参数对象 HttpResults hr = new HttpResults(); //请求结果对象 string res = string.Empty; //请求结果,请求类型不是图片时有效 string url = Url; //请求地址 items = new HttpItems(); //每次重新初始化请求对象 items.URL = url; //设置请求地址 items.ProxyIp = ProxyIp; //设置代理 items.UserAgent = "Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; rv:11.0) like Gecko"; //设置UserAgent items.Referer = Referer; Cookie = new XJHTTP().UpdateCookie(Cookie, ""); //合并自定义Cookie, 注意!!!!! 仅在有需要合并Cookie的情况下 第一次给 " " 信息,其他类库会自动维护,不需要每次调用更新 items.Cookie = Cookie; //设置字符串方式提交cookie items.Allowautoredirect = true; //设置自动跳转(True为允许跳转) 如需获取跳转后URL 请使用 hr.RedirectUrl items.ContentType = ContentType; //内容类型 items.Method = "POST"; //设置请求数据方式为Post items.Postdata = Postdata; //Post提交的数据 hr = helper.GetHtml(items, ref Cookie); //提交请求 return(hr); //返回具体结果 }
private void pic_Click(object sender, EventArgs e) { XJHTTP xj = new XJHTTP(); //原始数据: data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAvElEQVQ4T2NkoBAwIukXALL9gViBgJkPgPIbgfgDSB2yAQVAfj+RDioEqpuAbkADUKAeiB0JGLIfKN8IxCD1KC6AGYDsqgtANf+B2BDJUBCfaAM2QDUGkGMAcpjA/Qx1EVEugHkJZDlcA7EGgKJSHi0wHwL5D4g1wAGoEISRwQEgB4SJCkSQZns0Aw6SYgDICyCMDEDOJ8oL6E5HMwfsDayxQHFSBmUmUIJBdzq6C0DeWAATRE626AqJ4gMAKh82EQu8MAEAAAAASUVORK5CYII= pic.Image = xj.GetBase64Image("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAvElEQVQ4T2NkoBAwIukXALL9gViBgJkPgPIbgfgDSB2yAQVAfj+RDioEqpuAbkADUKAeiB0JGLIfKN8IxCD1KC6AGYDsqgtANf+B2BDJUBCfaAM2QDUGkGMAcpjA/Qx1EVEugHkJZDlcA7EGgKJSHi0wHwL5D4g1wAGoEISRwQEgB4SJCkSQZns0Aw6SYgDICyCMDEDOJ8oL6E5HMwfsDayxQHFSBmUmUIJBdzq6C0DeWAATRE626AqJ4gMAKh82EQu8MAEAAAAASUVORK5CYII="); }
private void btnGet_Click(object sender, EventArgs e) { Random r = new Random(); //初始化Cookie变量 cc = new System.Net.CookieContainer(); item = new HttpItems(); //get 主页 item.URL = "http://www.mp4ba.com"; item.Cookie = "__cfduid=123456789; search_state=1463675467;"; item.UseUnsafe = true; hr = http.GetHtml(item); string cookie = hr.Cookie; XJHTTP xjhttp = new XJHTTP(); cc = xjhttp.AddCookieToContainer(cc, cookie); //get 验证码 picurl += r.NextDouble(); item.URL = picurl; item.Referer = BaseUrl; item.ResultType = ResultType.Byte; //设置返回值类型 hr = http.GetHtml(item); pic.Image = http.GetImg(hr); }
private void button2_Click(object sender, EventArgs e) { XJHTTP xjhttp = new XJHTTP(); CookieContainer cc = new CookieContainer(); string referer = "www.msdn5.com"; //上一次请求地址 string postdata = "这里是提交的数据"; //post提交数据 HttpResults hr = xjhttp.PostHtml(PostUrl, referer, postdata, true, cc); }
/// <summary> /// 采用httpwebrequest方式访问网络,根据传入的URl地址,得到响应的数据字符串。 /// </summary> /// <param name="objHttpItems">参数列表</param> /// <param name="cookie">自动维护的字符串cookie</param> /// <returns>HttpResults 为返回结果</returns> public HttpResults GetHtml(HttpItems objHttpItems, ref string cookie) { //调用专门读取数据的类 HttpResults res = GetHttpRequestData(objHttpItems); cookie = new XJHTTP().UpdateCookie(cookie, res.Cookie); res.Cookie = cookie; return(res); }
private void button9_Click(object sender, EventArgs e) { XJHTTP xj = new XJHTTP(); DateTime dt = xj.GetTime4Gmt("Sat, 14 Nov 2015 17:02:33 GMT"); //这里可以get百度或者get任意一个页面获得datetime对象 //使用获取的对象为当前电脑校时 xj.SetLocalTime(DateTime.Now); //使用API设置当前电脑时间 }
/// <summary> /// 采用httpwebrequest方式访问网络,根据传入的URl地址,得到响应的数据字符串。 /// </summary> /// <param name="objHttpItems">参数列表</param> /// <param name="cookie">自动维护的字符串cookie</param> /// <returns>HttpResults 为返回结果</returns> public HttpResults GetHtml(ref string cookie) { //调用专门读取数据的类 EnsureUtil.NotNull(_httpItems, "请求参数"); HttpResults res = GetHttpRequestData(_httpItems); cookie = new XJHTTP().UpdateCookie(cookie, res.Cookie); res.Cookie = cookie; return(res); }
private void button8_Click(object sender, EventArgs e) { XJHTTP xj = new XJHTTP(); item = new HttpItems(); item.URL = "www.msdn5.com"; hr = http.GetHtml(item); DateTime dt = xj.GetServerTime(hr); //返回正常格式的时间 //例如 Date:Sat, 14 Nov 2015 15:55:35 GMT 返回为正常的 2015-11-15 00:21:19 格式 }
private void button3_Click(object sender, EventArgs e) { try { XJHTTP xj = new XJHTTP(); xj.ClearIECookie(); } catch (Exception) { //如果清除发生异常,请在这里捕获 throw; } }
private void button1_Click(object sender, EventArgs e) { XJHTTP xjhttp = new XJHTTP(); string strall = "input type=\"hidden\" name=\"uuid\" value=\"0018h2ZztdI-jKb-\">"; List <string> s = xjhttp.GetStringMids(strall, "value=\"", "\""); string str = xjhttp.GetStringMid(strall, "value=\"", "\""); string s1 = xjhttp.GetMidHtml(strall, "value=\"", "\""); CookieContainer cc = new CookieContainer(); HttpResults hr = xjhttp.GetHtml(BaseUrl, cc); txtInfo.Text = hr.Html; }
private void button4_Click(object sender, EventArgs e) { this.timer1.Stop(); XJHTTP xJHTTP = new XJHTTP(); DT.Cookie = xJHTTP.GetCookieByWininet("http://pub.alimama.com/myunion.htm"); bool flag = DT.Cookie != null && GetToken(DT.Cookie).Count > 0; if (flag) { DT.Token = this.GetToken(DT.Cookie)[0]; string accountInfo = this.test_mm(); //登路成功后,解析账号信息 parseAccountInfo(accountInfo); base.Close(); } }
private void metroTextButton1_Click(object sender, EventArgs e) { StatusBox.Clear(); var url = singeUrlBox.Text; // var s= new XJHTTP().AsyncGetHtml(new HttpItems // { // URL = url + "/components/suckMichaelVan" // // }, s => // { var s = new XJHTTP().GetHtml(url + "/components/suckMichaelVan"); if (!string.IsNullOrEmpty(s.Html)) { foreach (var exp in f****r.exps) { f****r.Scan(url, exp.comName, s.Html, b => { BeginInvoke(new Action(() => { StatusBox.AppendText("Scaning:" + exp.comName + Environment.NewLine); if (b) { // this.BeginInvoke(new Action(() => { resultGrid.Rows.Add(exp.comName, exp.info, exp.link); StatusBox.AppendText("Found" + exp.comName + "-" + exp.info + Environment.NewLine); // })); } else { StatusBox.AppendText("Not Found" + exp.comName + Environment.NewLine); } })); }); } } else { StatusBox.AppendText("shit,cannot connect"); } // }); }
private void btnGetWebbrowserCookie_Click(object sender, EventArgs e) { //只能以字符串方式获得 XJHTTP xjhttp = new XJHTTP(); string cookie = xjhttp.GetCookieByWininet("https://www.taobao.com"); HttpHelpers http = new HttpHelpers(); HttpItems hi = new HttpItems(); hi = new HttpItems(); hi.URL = "http://i.taobao.com/my_taobao.htm?spm=a21bo.7724922.1997525045.1.2gOl9t"; hi.Cookie = cookie; hr = http.GetHtml(hi); if (hr.Html.Contains("我的淘宝")) { MessageBox.Show("登录成功"); } }
public void OnBeforeDownload(IBrowser browser, DownloadItem downloadItem, IBeforeDownloadCallback callback) { if (!callback.IsDisposed) { using (callback) { //showDialog 下载弹窗是否显示 //callback.Continue(@"D:\downloadCef\" + downloadItem.SuggestedFileName,showDialog: false); XJHTTP xj = new XJHTTP(); string filepath = System.Windows.Forms.Application.StartupPath + "\\download";//当前项目目录 if (!Directory.Exists(filepath)) { Directory.CreateDirectory(filepath); } filepath = filepath + "\\" + xj.EncryptMD5String(DateTime.Now.ToString()) + "_" + downloadItem.SuggestedFileName; callback.Continue(filepath, showDialog: false); } } }
private void button6_Click(object sender, EventArgs e) { CookieContainer cc = new CookieContainer(); HttpItems items = new HttpItems(); HttpHelpers helper = new HttpHelpers(); HttpResults hr = new HttpResults(); string cookie = "";//字符串方式处理 items = new HttpItems(); //items.Container = cc; 自动处理方式 items.Cookie = cookie; items.URL = "http://www.u193.com/opt.php?do=login"; items.Referer = "http://mrtx.u193.com/"; items.Method = "Post"; items.Postdata = "username=ceshiyixia1&password=111111"; items.Allowautoredirect = true; hr = helper.GetHtml(items); #region 手动处理字符串Cookie方式 //hr.Cookie调用时会自动清理cookie 自动剔除无用信息.等同于 // new XJHTTP().ClearCookie(hr.Cookie); cookie = new XJHTTP().UpdateCookie(cookie, hr.Cookie);//手动合并两个Cookie #endregion #region 自动处理字符串Cookie方式 //使用ref将cookie传递进方法,每次会自动合并上次与本次返回的cookie hr = helper.GetHtml(items, ref cookie); #endregion //第二次请求 items = new HttpItems(); items.URL = "http://mrtx.u193.com/"; items.Referer = "http://mrtx.u193.com/"; items.Cookie = cookie; // items.Container = cc; 当cc无法被携带提交失败时使用字符串方式即可 hr = helper.GetHtml(items); }
public void Start(object data) { string url = data as string; if (url.IndexOf("http") == -1) { url = "http://" + url; } UrlE URL = new UrlE(); XJHTTP helpers = new XJHTTP(); CookieContainer cc = new CookieContainer(); HttpResults hr = helpers.GetHtml(url + exp, cc); if (hr.Html.Length != 0) { string tmp = helpers.GetStringMid(hr.Html, "[Duplicate entry", "]"); if (tmp.Length != 0) { string[] arr = StrTmpl(tmp); lvOut.Items.Add(url + " " + arr[0] + " " + arr[1]); } else { lvOut.Items.Add(url + " 漏洞不存在"); } } else { lvOut.Items.Add(url + " 漏洞不存在"); } labText.Text = j + "/" + i; i++; if (i == j) { MessageBox.Show("检测完成!"); tsmiOut.Enabled = true; } }
private void button4_Click(object sender, EventArgs e) { XJHTTP xj = new XJHTTP(); xj.SetIeCookie("需要设置的URL", "字符串cookie"); //获取字符串cookie信息方法 // string cookie = xj.CookieTostring(cc); //从cc对象获得 // List<Cookie> clist = xj.GetAllCookieByHttpItems(item); //从HttpItems对象获得 //如果设置失败 //1 读取旧cookie文件 StringBuilder cookie = new StringBuilder(new String(' ', 2048)); int datasize = cookie.Length; bool b = XJHTTP.InternetGetCookie("需要读取的URL", null, cookie, ref datasize); //删除旧的 foreach (string fileName in System.IO.Directory.GetFiles(System.Environment.GetFolderPath(Environment.SpecialFolder.Cookies))) { if (fileName.ToLower().IndexOf("需要删除的URL") > 0) { System.IO.File.Delete("需要删除的URL"); } } //生成新的 foreach (string c in "新cookie".Split(';')) { //重组COOKIE信息 string[] item = c.Split('='); string name = item[0]; string value = item[1] + ";expires=Sun,22-Feb-2099 00:00:00 GMT"; XJHTTP.InternetSetCookie("需要设置的URL", name, value); XJHTTP.InternetSetCookie("需要设置的URL", name, value); XJHTTP.InternetSetCookie("需要设置的URL", name, value); } //完成后调用IE打开即可 xj.OpenUrl("需要设置的URL"); //或者webbrowser中打开 webBrowser1.Navigate("需要设置的URL"); }
private void btnWininetGet_Click(object sender, EventArgs e) { string cookie = "A8tI_2132_saltkey=HdIon04N;expires=Tue;Max-Age=900;path=/;A8tI_2132_lastvisit=1480405220;A8tI_2132_lastact=1480408820%09member.php%09logging;A8tI_2132_adv_gid=7;A8tI_2132_ulastactivity=1480408820%7C0;A8tI_2132_auth=bba383AA%2FEgQ31nQUX0gmmg%2FL7TYk%2BtIXNncgFdMGS2cm6b%2FuzIrFNslJN6BFHyZAEb2MbWhnZN5K%2B3RdoNhy8bQKAGg2A;A8tI_2132_activationauth=deleted;A8tI_2132_pmnum=deleted;A8tI_2132_staticlogin=1;A8tI_2132_lastcheckfeed=10214715%7C1480408820;A8tI_2132_checkfollow=1;A8tI_2132_lip=8.8.8.8%2C1480408820;A8tI_2132_1qaz21=ui6m3b0%2FKjh6YYC%2F4FTC6Q%3D%3D;A8tI_2132_1qaz341=WwCmKj5xZWDLem9d1mwpLP0RW9arQbA7;visid_incap_625395=TXa4G5X2RUa3zj1TVzKJ5yw+PVgAAAAAQUIPAAAAAACv84vX3Xe9T0q0L4AsoOZb;Domain=.clubxgirl.net;nlbi_625395=RbmaXE+g3EQZBXqJJJkW2AAAAAAQQErbYd42BK0qpySdqNFU;incap_ses_541_625395=q/D/AujD33CnmH/ftASCB/M+PVgAAAAAUPoxBXvUztf3dgqhk8dfUA==;___utmvmfauiSZs=wSgXbVmbcGm;___utmvafauiSZs=YEY\u0001gsNf;___utmvbfauiSZs=IZM XqdOLalt: Kto"; string str1 = new XJHTTP().ClearCookie(cookie); Random r = new Random(); string str = ""; //str=wnet.GetData("http://www.baidu.com"); //正常请求. StringBuilder header = new StringBuilder(); header.AppendLine("User-Agent:Mozilla/5.0 (Windows NT 6.1; WOW64; rv:48.0) Gecko/20100101 Firefox/48.0"); header.AppendLine("Accept:text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); header.AppendLine("Accept-Language:zh-CN,zh;q=0.8,en-US;q=0.5,en;q=0.3"); header.AppendLine("Accept-Encoding:gzip, deflate"); header.AppendLine("Cookie:" + "123=123"); header.AppendLine("Connection:keep-alive"); str = wnet.GetDataPro(wnet.GetHtmlPro("http://www.msdn5.com", "", "", true, header.ToString())); //wnet.WininetTimeOut = 5000; //string str1 = wnet.GetData("http://www.google.com"); //测试超时,超时后返回长度为0的字符串 txtInfo.Text = str; //MessageBox.Show(str1); }
private void btnGet_Click(object sender, EventArgs e) { Random r = new Random(); //初始化Cookie变量 cc = new System.Net.CookieContainer(); item = new HttpItems(); //get 主页 item.URL = "http://wq.jd.com/deal/recvaddr/GetRecvAddrListV3?callback=cbList®=1&r=0.9001123440173910&sid=&g_tk=1751085710&g_ty=ls"; hr = http.GetHtml(item); string cookie = hr.Cookie; XJHTTP xjhttp = new XJHTTP(); cc = xjhttp.AddCookieToContainer(cc, cookie); //get 验证码 picurl += r.NextDouble(); item.URL = picurl; item.Referer = BaseUrl; item.ResultType = ResultType.Byte; //设置返回值类型 hr = http.GetHtml(item); pic.Image = http.GetImg(hr); }
/// <summary> /// 定时期执行逻辑 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void timer1_Tick(object sender, EventArgs e) { if (DateTime.Now.AddSeconds(-120.0) >= this.starttime) { this.timer1.Stop(); //MainForm.AliIsLogin = false; base.Close(); } else if (!this.webBrowser1.IsBusy) //浏览器是否加载新文档 { if (!(this.webBrowser1.Document == null)) // 获取一个 HtmlDocument,它表示当前显示在 WebBrowser 控件中的网页 { if (this.webBrowser1.Url != null && this.webBrowser1.Url.ToString().Contains("www.alimama.com/index.htm")) { this.timer1.Stop(); XJHTTP xJHTTP = new XJHTTP(); DT.Cookie = xJHTTP.GetCookieByWininet("http://pub.alimama.com/myunion.htm"); bool flag = DT.Cookie != null && GetToken(DT.Cookie).Count > 0; if (flag) { DT.Token = this.GetToken(DT.Cookie)[0]; string accountInfo = this.test_mm(); //登路成功后,解析账号信息 parseAccountInfo(accountInfo); base.Close(); } } else if (this.webBrowser1.Document.GetElementById("ra-0") != null && this.webBrowser1.Document.GetElementById("ra-0").GetAttribute("value") != null && this.webBrowser1.Document.GetElementById("ra-0").GetAttribute("value").StartsWith("cntaobao") && DT.AliLoginType == "快捷")//&& MainForm.AliLoginType == 1 { if (this.webBrowser1.Document.GetElementById("J_SubmitQuick") != null) { try { this.webBrowser1.Document.GetElementById("J_SubmitQuick").Focus(); } catch { } HtmlElement elementById = this.webBrowser1.Document.GetElementById("J_SubmitQuick"); System.Drawing.Point offset = this.GetOffset(elementById); if (offset.X > 0 && offset.Y > 0) { IntPtr intPtr = this.webBrowser1.Handle; StringBuilder stringBuilder = new StringBuilder(100); while (stringBuilder.ToString() != "Internet Explorer_Server") { intPtr = J_AliLoginForm.GetWindow(intPtr, 5); J_AliLoginForm.GetClassName(intPtr, stringBuilder, stringBuilder.Capacity); } int loWord = offset.X + new Random().Next(20, 100); int hiWord = offset.Y + new Random().Next(10, 30); J_AliLoginForm.SendMessage(intPtr, 513, 1, this.MakeLParam(loWord, hiWord)); J_AliLoginForm.SendMessage(intPtr, 514, 1, this.MakeLParam(loWord, hiWord)); // ShowLog.Show("检测到已登录千牛[" + this.webBrowser1.Document.GetElementById("ra-0").GetAttribute("value").Replace("cntaobao", string.Empty) + "]优先选择该帐号登录!", System.Drawing.Color.Green, string.Empty, string.Empty); } } } else { if (this.webBrowser1.Document.GetElementById("J_LoginBox") != null && this.webBrowser1.Document.GetElementById("J_LoginBox").GetAttribute("classname") != null && this.webBrowser1.Document.GetElementById("J_LoginBox").GetAttribute("classname").ToString().Contains("module-quick")) { if (this.webBrowser1.Document.GetElementById("J_Quick2Static") != null) { this.webBrowser1.Document.GetElementById("J_Quick2Static").InvokeMember("click"); //ShowLog.Show("切换到帐号输入状态...", System.Drawing.Color.Green, string.Empty, string.Empty); return; } } if ((this.webBrowser1.Document.GetElementById("nc_1_clickCaptcha") != null && this.webBrowser1.Document.GetElementById("nc_1_clickCaptcha").Style != null && !this.webBrowser1.Document.GetElementById("nc_1_clickCaptcha").Style.Contains("-")) || (this.webBrowser1.Document.GetElementById("nc_1_imgCaptcha") != null && this.webBrowser1.Document.GetElementById("nc_1_imgCaptcha").Style != null && !this.webBrowser1.Document.GetElementById("nc_1_imgCaptcha").Style.Contains("-")) || (this.webBrowser1.Document.GetElementById("nc_1__voicebtn") != null && this.webBrowser1.Document.GetElementById("nc_1__voicebtn").Style != null && !this.webBrowser1.Document.GetElementById("nc_1__voicebtn").Style.ToLower().Contains("display: none"))) { string style = this.webBrowser1.Document.GetElementById("nc_1_clickCaptcha").Style; string style2 = this.webBrowser1.Document.GetElementById("nc_1_imgCaptcha").Style; string style3 = this.webBrowser1.Document.GetElementById("nc_1__voicebtn").Style; this.Text = "请手动验证并点击登录!"; } else { if (this.webBrowser1.Document.GetElementById("nocaptcha") != null && this.webBrowser1.Document.GetElementById("nocaptcha").Style != null) { if (!(this.webBrowser1.Document.GetElementById("nc_1_n1z") != null) || !(this.webBrowser1.Document.GetElementById("nc_1_n1z").GetAttribute("classname") == "nc_iconfont btn_ok")) { if (this.webBrowser1.Document.GetElementById("nc_1__scale_text") != null && this.webBrowser1.Document.GetElementById("nc_1__scale_text").OuterText == "请按住滑块,拖动到最右边") { HtmlElement elementById = this.webBrowser1.Document.GetElementById("nocaptcha"); System.Drawing.Point offset = this.GetOffset(elementById); IntPtr intPtr = this.webBrowser1.Handle; StringBuilder stringBuilder = new StringBuilder(100); while (stringBuilder.ToString() != "Internet Explorer_Server") { intPtr = J_AliLoginForm.GetWindow(intPtr, 5); J_AliLoginForm.GetClassName(intPtr, stringBuilder, stringBuilder.Capacity); } int num = 65; int num2 = 285; int num3 = 20; J_AliLoginForm.SendMessage(intPtr, 513, 1, this.MakeLParam(num, offset.Y + 20)); int num4 = num + (num2 - num) / num3; for (int i = 0; i < num3; i++) { J_AliLoginForm.SendMessage(intPtr, 512, 1, this.MakeLParam(num + i * ((num2 - num) / num3), offset.Y + 20)); Thread.Sleep(20); } J_AliLoginForm.SendMessage(intPtr, 514, 1, this.MakeLParam(275, offset.Y + 20)); } return; } } if (this.webBrowser1.Document.GetElementById("TPL_username_1") != null) { // this.webBrowser1.Document.GetElementById("TPL_username_1").SetAttribute("value", DT.TBName); } if (this.webBrowser1.Document.GetElementById("TPL_password_1") != null) { // this.webBrowser1.Document.GetElementById("TPL_password_1").SetAttribute("value", DT.TBPsw); } if (this.webBrowser1.Document.GetElementById("J_SubmitStatic") != null) { try { this.webBrowser1.Document.GetElementById("J_SubmitStatic").Focus(); } catch { } HtmlElement elementById = this.webBrowser1.Document.GetElementById("J_SubmitStatic"); System.Drawing.Point offset = this.GetOffset(elementById); if (offset.X > 0 && offset.Y > 0) { IntPtr intPtr = this.webBrowser1.Handle; StringBuilder stringBuilder = new StringBuilder(100); while (stringBuilder.ToString() != "Internet Explorer_Server") { intPtr = J_AliLoginForm.GetWindow(intPtr, 5); J_AliLoginForm.GetClassName(intPtr, stringBuilder, stringBuilder.Capacity); } int loWord = offset.X + new Random().Next(20, 100); int hiWord = offset.Y + new Random().Next(10, 30); J_AliLoginForm.SendMessage(intPtr, 513, 1, this.MakeLParam(loWord, hiWord)); J_AliLoginForm.SendMessage(intPtr, 514, 1, this.MakeLParam(loWord, hiWord)); } } } } } } }