/// <summary> /// 获取证书编号对应详情 /// </summary> /// <param name="Certi_No"></param> private Dictionary <String, String> TUVLY_Details(String Certi_No) { Dictionary <String, String> dirs = new Dictionary <string, string>(); String html = "start"; String newcertino = Certi_No.Substring(1, Certi_No.Length - 1); try { HttpInfo info = new HttpInfo(); info.RequestUrl = String.Format(TUVLY_Details_Url, newcertino); while (!html.Contains(newcertino) || !html.Contains("Certificate No")) { //info.Ip = html = HttpMethod.HttpWork(info); Thread.Sleep(1); } if (html.Contains(newcertino)) { //处理数据 var strs = XpathMethod.GetMutResult(xpath_certi, html, 0); foreach (var str in strs) { if (XpathMethod.GetSingleResult(xpath_title, str, 1).Replace(": ", "") != "Certificate Holder") { dirs.Add(XpathMethod.GetSingleResult(xpath_title, str, 1).Replace(": ", ""), XpathMethod.GetSingleResult(xpath_details, str, 1).Replace("\n", "")); } } } } catch { } return(dirs); }
/// <summary> /// 获取证书编号对应详情 /// </summary> /// <param name="Certi_No"></param> private Dictionary <String, String> CQC_Details(String Certi_No) { Dictionary <String, String> dirs = new Dictionary <string, string>(); HttpInfo info = new HttpInfo(); String html = "start"; String code = String.Empty; String cookie = Get_Cookie(CQC_Details_Url); try { while (!html.Contains(Certi_No) || html.Contains("验证码输入有误") || html.Contains("请输入验证码")) { code = WmCodeHelper.Get_Code(cookie); info.RequestUrl = CQC_Details_Url; info.PostData = String.Format(CQC_PostData, Certi_No, code); info.Cookie = new CookieString(cookie, true); //info.Ip = ""; html = HttpMethod.HttpWork(info); Thread.Sleep(1); } if (html.Contains(Certi_No)) { //数据处理 var ths = XpathMethod.GetMutResult(xpath_title, html, 1); var strs = XpathMethod.GetMutResult(xpath_certi, html, 1); string fjurl = XpathMethod.GetSingleResult(xpath_certi + "[14]", html, 0); fjurl = RegexMethod.GetSingleResult(reg_fjurl, fjurl, 1); for (int i = 1; i < strs.Count; i++) { if (i == strs.Count - 1 && !String.IsNullOrEmpty(fjurl)) { dirs.Add(ths[i], fjurl); } else { dirs.Add(ths[i], strs[i]); } } //CCCInfo cccinfo = new CCCInfo(); //cccinfo.CertiNo = XpathMethod.GetSingleResult(xpath_certino, html); //cccinfo.Applicant = XpathMethod.GetSingleResult(xpath_appli1, html) + "\r\n" + XpathMethod.GetSingleResult(xpath_appli2, html); } } catch { } return(dirs); }
/// <summary> /// Xpath抽取匹配结果 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void barButtonItem7_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { if (String.IsNullOrEmpty(textEdit11.Text)) { Form4 form4 = new Form4("错误:Xpath表达式为空"); form4.Text = "错误"; form4.ShowDialog(); return; } richEditControl7.Text = ""; String text = checkEdit6.Checked ? Jhtml : html; //标识匹配或抽取 int flag = 1; if (checkEdit9.Checked) { flag = 0; } if (checkEdit10.Checked) { flag = 1; } if (checkEdit8.Checked) { try { var list = String.IsNullOrEmpty(textEdit12.Text) ? XpathMethod.GetMutResult(textEdit11.Text, text, flag) : XpathMethod.GetMutResult(textEdit11.Text, text, textEdit12.Text); richEditControl7.Text = String.Join("\n", list); } catch { richEditControl7.Text = "抽取失败"; } } else { try { richEditControl7.Text = String.IsNullOrEmpty(textEdit12.Text) ? XpathMethod.GetSingleResult(textEdit11.Text, text, flag) : XpathMethod.GetSingleResult(textEdit11.Text, text, textEdit12.Text); } catch { richEditControl7.Text = "抽取失败"; } } barStaticItem1.Caption = "当前状态:Xpath抽取完成"; }
private void button7_Click(object sender, EventArgs e) { if (String.IsNullOrEmpty(textBox15.Text)) { MessageBox.Show("Xpath为空"); return; } richTextBox2.Clear(); String text = checkBox6.Checked ? JsHtml : html; //标识匹配或抽取 int flag = 1; if (radioButton1.Checked) { flag = 0; } else if (radioButton2.Checked) { flag = 1; } if (checkBox5.Checked) { try { var list = String.IsNullOrEmpty(textBox16.Text) ? XpathMethod.GetMutResult(textBox15.Text, text, flag) : XpathMethod.GetMutResult(textBox15.Text, text, textBox16.Text); richTextBox2.Text = String.Join("\n", list); } catch { richTextBox2.Text = "抽取失败"; } } else { try { richTextBox2.Text = String.IsNullOrEmpty(textBox16.Text) ? XpathMethod.GetSingleResult(textBox15.Text, text, flag) : XpathMethod.GetSingleResult(textBox15.Text, text, textBox16.Text); } catch { richTextBox2.Text = "抽取失败"; } } }
private Dictionary <String, String> GetData(string html) { Dictionary <String, String> dirs = new Dictionary <string, string>(); var trs = XpathMethod.GetMutResult("//*[@id=\"certificatedetails\"]/table/tr", html, 0); foreach (var tr in trs) { var valign = XpathMethod.GetSingleResult("tr", tr, "valign"); if (valign.Trim().ToUpper().Equals("TOP")) { var name = XpathMethod.GetSingleResult("tr/td[1]", tr); var value = XpathMethod.GetSingleResult("tr/td[2]", tr); if (!name.Contains("ASTA BEAB Ref") && !name.Contains("Characteristics") && !name.Contains("Licenced Mark") && !name.Contains("Additional Info")) { dirs.Add(Fitlter(name, ":"), Fitlter(value)); } } } return(dirs); }
/// <summary> /// 请求获取详细信息 /// </summary> /// <param name="Certi_No"></param> public static Dictionary <string, string> VDE_Details(String Certi_No) { Dictionary <String, String> dirs = new Dictionary <string, string>(); String Html = String.Empty; String newpostdata = String.Empty; String typedata = String.Empty; try { String postdata = GetPostData(Certi_No); String cid = GetCid(postdata, ref newpostdata); HttpInfo info = new HttpInfo(); info.RequestUrl = String.Format(Details_Url, cid); info.PostData = newpostdata; info.AllowAutoRedirect = true; while (!Html.Contains("Details")) { Html = HttpMethod.HttpWork(info); Thread.Sleep(1); } dirs.Add("CertificateNo", Certi_No); var trs = XpathMethod.GetMutResult(xpath_title, Html, 0); foreach (var tr in trs) { if (XpathMethod.GetSingleResult(xpath_details + "[1]", tr, 1) != "Certification mark") { dirs.Add(XpathMethod.GetSingleResult(xpath_details + "[1]", tr, 1), XpathMethod.GetSingleResult(xpath_details + "[2]", tr, 1)); } } if (Html.Contains("Additional information")) { dirs.Add("Additional", "Additional information"); } else { dirs.Add("Additional", ""); } dirs.Add(XpathMethod.GetSingleResult(xpath_stand + "[1]", Html, 1).Replace("<.*>", ""), XpathMethod.GetSingleResult(xpath_stand + "[2]", Html, 1).Replace("<.*>\\s+", "").Replace("\\s+<.*>", "").Replace("<.*>", "")); var typetrs = XpathMethod.GetMutResult(xpath_Type, Html, 0); for (int i = 1; i < typetrs.Count; i++) { if (i == typetrs.Count - 1) { typedata = typedata + XpathMethod.GetSingleResult("tr/td[1]", typetrs[i], 1).Replace("²", "") + ";" + XpathMethod.GetSingleResult("tr/td[2]", typetrs[i], 1).Replace(" ", "").Replace("²", ""); } else { typedata = typedata + XpathMethod.GetSingleResult("tr/td[1]", typetrs[i], 1).Replace("²", "") + ";" + XpathMethod.GetSingleResult("tr/td[2]", typetrs[i], 1).Replace(" ", "").Replace("²", ""); } } dirs.Add("Type-Techical Data", "Type and Technical Data" + ";" + typedata); dirs.Add("Type", typedata); foreach (var item in dirs.Keys) { Console.Write(item + ","); } } catch { } return(dirs); }