private void button6_Click(object sender, EventArgs e) { if (String.IsNullOrEmpty(html)) { MessageBox.Show("网页源码为空"); return; } if (String.IsNullOrEmpty(textBox13.Text)) { MessageBox.Show("正则表达式为空"); return; } if (String.IsNullOrEmpty(textBox14.Text)) { MessageBox.Show("层数为空,将使用默认值0"); textBox14.Text = "0"; } int lay = Convert.ToInt32(textBox14.Text); if (checkBox4.Checked) { try { var list = RegexMethod.GetMutResult(textBox13.Text, html, lay); richTextBox1.Text = String.Join("\n", list); } catch { richTextBox1.Text = "未找到匹配结果"; } } else { try { richTextBox1.Text = RegexMethod.GetSingleResult(textBox13.Text, html, lay); } catch { richTextBox1.Text = "未找到匹配结果"; } } }
/// <summary> /// 请求获取详细信息 /// </summary> /// <param name="Certi_No"></param> public static Dictionary <string, string> TUVnd_Details(String Certi_No) { Dictionary <string, string> dirs = new Dictionary <string, string>(); String html = "start"; try { HttpInfo info = new HttpInfo(); info.RequestUrl = String.Format(Url, Certi_No); while (!html.Contains(Certi_No)) { html = HttpMethod.HttpWork(info); Thread.Sleep(1); } //处理数据 var list = RegexMethod.GetMutResult(reg_all, html, 1); int i = 0; foreach (var item in list) { if (item.Contains("cert_details_th")) { String title = RegexMethod.GetSingleResult(reg_title, item, 1); String details = RegexMethod.GetSingleResult(reg_details, item, 1); if (title != " " && details != " ") { if (String.IsNullOrEmpty(title)) { i++; title = "Custom" + i; } dirs.Add(title, details); } } } } catch { } return(dirs); }
/// <summary> /// 配置请求头 /// </summary> /// <returns></returns> public HttpInfo CreateHttp() { HttpInfo info = new HttpInfo(); #region 请求头配置 info = new HttpInfo(textEdit1.Text); if (!String.IsNullOrEmpty(richEditControl1.Text)) { var list = RegexMethod.GetMutResult("[\u4e00-\u9fa5]+?", richEditControl1.Text); String newpostdata = richEditControl1.Text; for (int i = 0; i < list.Count; i++) { newpostdata = newpostdata.Replace(list[i], HttpMethod.URLEncode(list[i])); } info.PostData = newpostdata; } info.UseSystemProxy = checkEdit7.Checked; //info.Host = textBox17.Text; info.IgnoreWebException = true; info.User_Agent = textEdit2.Text; info.Referer = textEdit4.Text; info.ContentType = textEdit3.Text; info.Accept = textEdit5.Text; info.AcceptEncoding = textEdit6.Text; info.CheckUrl = checkEdit4.Checked; info.Expect100Continue = checkEdit5.Checked; if (!String.IsNullOrEmpty(textEdit8.Text)) { info.Encoding = Encoding.GetEncoding(textEdit8.Text); } if (!String.IsNullOrEmpty(richEditControl2.Text)) { info.Cookie = new CookieString(richEditControl2.Text, true); } else { info.CC = new CookieContainer(); } info.AllowAutoRedirect = checkEdit1.Checked; info.KeepLive = checkEdit2.Checked; if (checkEdit3.Checked) { info.Header.Add("X-Requested-With", "XMLHttpRequest"); } foreach (var item in HeadDic) { if (item.Key == "Host") { info.Host = item.Value; continue; } if (item.Key == "ProtocolVersion") { if (item.Value == "1.0") { info.ProtocolVersion = ProtocolVersionEnum.V10; } else { info.ProtocolVersion = ProtocolVersionEnum.V11; } continue; } if (item.Key == "proxy") { var arr = item.Value.Split('|'); if (arr.Length > 0) { info.Ip = arr[0]; } if (arr.Length > 1) { info.Proxy_UserName = arr[1]; } if (arr.Length > 2) { info.Proxy_PassWord = arr[2]; } continue; } info.Header.Add(item.Key, item.Value); } #endregion return(info); }