protected override IList ExecuteCrawl(bool crawlAll) { IList list = new List <BidSituation>(); int sqlCount = 0; string html = string.Empty; try { html = this.ToolWebSite.GetHtmlByUrl(this.SiteUrl + this.MaxCount); } catch { return(null); } int startIndex = html.IndexOf("{"); int endIndex = html.LastIndexOf("}"); html = html.Substring(startIndex, (endIndex + 1) - startIndex); JavaScriptSerializer serializer = new JavaScriptSerializer(); Dictionary <string, object> smsTypeJson = (Dictionary <string, object>)serializer.DeserializeObject(html); object[] objvalues = smsTypeJson["rows"] as object[]; foreach (object objValue in objvalues) { Dictionary <string, object> dic = (Dictionary <string, object>)objValue; string code = string.Empty, prjName = string.Empty, PublicityEndDate = string.Empty, InfoUrl = string.Empty, msgType = string.Empty, ctx = string.Empty, HtmlTxt = string.Empty, beginDate = string.Empty; code = Convert.ToString(dic["bdBH"]); prjName = Convert.ToString(dic["bdName"]); beginDate = Convert.ToString(dic["faBuTime2"]); string idt = Convert.ToString(dic["bdGuid"]); InfoUrl = Convert.ToString(dic["detailUrl"]); string attachJson = string.Empty; try { string urll = "https://www.szjsjy.com.cn:8001/jyw-ba/jyxx/queryOldOTDataDetail.do?type=5&id=" + idt; HtmlTxt = this.ToolWebSite.GetHtmlByUrl(urll).GetJsString().GetReplace("\\t,\\r,\\n,\""); if (string.IsNullOrWhiteSpace(HtmlTxt)) { string kdGuid = Convert.ToString(dic["kbJiLuGuid"]); InfoUrl = "https://www.szjsjy.com.cn:8001/jyw-ba/jyxx/kbJiLu_View.do?kbJiLuGuid=" + kdGuid; HtmlTxt = this.ToolWebSite.GetHtmlByUrl(InfoUrl); string url = "https://www.szjsjy.com.cn:8001/jyw-ba/jyxx/querykbJiLuDetail.do?ggGuid=&bdGuid=&kbJiLuGuid=" + kdGuid; attachJson = this.ToolWebSite.GetHtmlByUrl(url); } } catch (Exception ex) { continue; } string gcBh = string.Empty, gcName = string.Empty, gcLeixing = string.Empty, jywTime = string.Empty, kbjiGuid = string.Empty, surl = string.Empty, attachId = string.Empty, attachFileGroupGuid = string.Empty; if (!string.IsNullOrWhiteSpace(attachJson)) { JavaScriptSerializer newSerializer = new JavaScriptSerializer(); Dictionary <string, object> newTypeJson = (Dictionary <string, object>)newSerializer.DeserializeObject(attachJson); Dictionary <string, object> kdInfo = (Dictionary <string, object>)newTypeJson["kbJiLu"]; try { attachId = Convert.ToString(kdInfo["kbJiLuGuid"]); attachFileGroupGuid = Convert.ToString(kdInfo["attachFileGroupGuid"]); } catch { } gcLeixing = Convert.ToString(kdInfo["gcLeiXing"]); jywTime = Convert.ToString(kdInfo["jywFaBuEndTime"]); //https://www.szjsjy.com.cn:8001/jyw-ba/jyxx/kbJiLu_View.do?kbJiLuGuid=9cb75eb8-66b6-441c-9686-471dfa357ff5 surl = "https://www.szjsjy.com.cn:8001/jyw-ba/jyxx/kbJiLu_View.do?kbJiLuGuid=" + attachFileGroupGuid; attachJson = this.ToolWebSite.GetHtmlByUrl(surl); HtmlTxt = attachJson; Parser parserNew = new Parser(new Lexer(HtmlTxt)); NodeList tableNode = parserNew.ExtractAllNodesThatMatch(new AndFilter(new TagNameFilter("table"), new HasAttributeFilter("class", "de_tab1"))); if (tableNode != null && tableNode.Count > 0) { HtmlTxt = tableNode.AsHtml(); HtmlTxt = HtmlTxt.GetReplace("<td id=\"bdBH\"> </td>", "<td id=\"bdBH\"> " + code + "</td>"); HtmlTxt = HtmlTxt.GetReplace("<td id=\"bdName\"> </td>", "<td id=\"bdName\"> " + prjName + "</td>"); HtmlTxt = HtmlTxt.GetReplace("<td id=\"gcLeiXing\"> </td>", "<td id=\"gcLeiXing\"> " + gcLeixing + "</td>"); HtmlTxt = HtmlTxt.GetReplace("<td id=\"jieZhiTime\"> </td>", "<td id=\"jieZhiTime\"> " + jywTime + "</td>"); ctx = HtmlTxt.Replace("</tr>", "\r\n").ToCtxString(); } } ctx = HtmlTxt.ToCtxString(); string saveUrl = Convert.ToString(dic["detailUrl"]); msgType = "深圳市建设工程交易中心宝安分中心"; BidSituation info = ToolDb.GetBidSituation("广东省", "深圳宝安区工程", "宝安区", code, prjName, PublicityEndDate, msgType, InfoUrl, ctx, HtmlTxt, beginDate); sqlCount++; if (!crawlAll && sqlCount >= this.MaxCount) { return(list); } if (ToolDb.SaveEntity(info, this.ExistCompareFields, this.ExistsUpdate, this.ExistsHtlCtx)) { if (!string.IsNullOrWhiteSpace(attachFileGroupGuid)) { string moJson = string.Empty; string sUrl = "https://www.szjsjy.com.cn:8001/jyw-ba/jyxx/filegroup/queryByGroupGuidZS.do?groupGuid=" + attachFileGroupGuid; try { moJson = this.ToolWebSite.GetHtmlByUrl(sUrl); } catch { } if (!string.IsNullOrWhiteSpace(moJson)) { JavaScriptSerializer newSerializers = new JavaScriptSerializer(); Dictionary <string, object> newTypeJsons = (Dictionary <string, object>)newSerializers.DeserializeObject(moJson); Dictionary <string, object> mofo = (Dictionary <string, object>)newTypeJsons; object[] objs = (object[])mofo["rows"]; foreach (object objAttach in objs) { Dictionary <string, object> attachs = (Dictionary <string, object>)objAttach; string attachguid = Convert.ToString(attachs["attachGuid"]); string attachName = Convert.ToString(attachs["attachName"]); string link = "https://www.szjsjy.com.cn:8001/file/downloadFile?fileId=" + attachguid; BaseAttach attach = ToolHtml.GetBaseAttach(link, attachName, info.Id, "SiteManage\\Files\\Attach\\"); if (attach != null) { ToolDb.SaveEntity(attach, "SourceID,AttachServerPath"); } } } } else { Parser parser = new Parser(new Lexer(HtmlTxt)); NodeList fileNode = parser.ExtractAllNodesThatMatch(new TagNameFilter("a")); if (fileNode != null && fileNode.Count > 0) { for (int f = 0; f < fileNode.Count; f++) { ATag tag = fileNode[f] as ATag; try { BaseAttach attach = null; string link = string.Empty; if (tag.Link.ToLower().Contains("http")) { link = tag.Link; if (link.Contains("\\")) { link = link.Replace("\\", ""); } } else { link = "https://www.szjsjy.com.cn:8001/" + tag.Link; } attach = ToolHtml.GetBaseAttach(link, tag.LinkText, info.Id, "SiteManage\\Files\\Attach\\"); if (attach != null) { ToolDb.SaveEntity(attach, "SourceID,AttachServerPath"); } } catch { continue; } } } } } } return(list); }
protected override IList ExecuteCrawl(bool crawlAll) { IList list = new List <BidSituation>(); string html = string.Empty; string cookiestr = string.Empty; string viewState = string.Empty; int pageInt = 1, sqlCount = 0; string eventValidation = string.Empty; string tempCookie = string.Empty; try { html = this.ToolWebSite.GetHtmlByUrl("http://jyzx.cb.gov.cn/LGjyzxWeb/SiteManage/Index.aspx", Encoding.UTF8, ref cookiestr); viewState = this.ToolWebSite.GetAspNetViewState(html); eventValidation = this.ToolWebSite.GetAspNetEventValidation(html); NameValueCollection n = this.ToolWebSite.GetNameValueCollection( new string[] { "ctl00$ScriptManager1", "__EVENTTARGET", "__EVENTARGUMENT", "__VIEWSTATE", "ctl00$cph_context$Login1$hfCertTitle", "ctl00$cph_context$DropDownList1", "ctl00$cph_context$DropDownList2", "select3", "textfield", "ctl00$cph_context$Login1$btnLogin.x", "ctl00$cph_context$Login1$btnLogin.y" }, new string[] { "ctl00$cph_context$Login1$upLogin|ctl00$cph_context$Login1$btnLogin", "", "", viewState, "CN=年度施工投标人7,OU=1007,L=深圳市,ST=广东省,C=CN", "", "", "=全文检索=", "输入查询内容", "22", "8" } ); html = this.ToolWebSite.GetHtmlByUrl("http://jyzx.cb.gov.cn/LGjyzxWeb/SiteManage/Index.aspx", n, Encoding.UTF8, ref tempCookie); html = this.ToolWebSite.GetHtmlByUrl(this.SiteUrl, Encoding.UTF8, ref tempCookie); } catch { return(list); } Parser parser = new Parser(new Lexer(html)); NodeList pageNode = parser.ExtractAllNodesThatMatch(new AndFilter(new TagNameFilter("table"), new HasAttributeFilter("class", "inside_table3_bottom"))); if (pageNode != null && pageNode.Count > 0) { try { string temp = pageNode[0].ToPlainTextString().GetRegexBegEnd(",共", "页"); pageInt = int.Parse(temp); } catch { } } for (int i = 1; i <= pageInt; i++) { if (i > 1) { viewState = this.ToolWebSite.GetAspNetViewState(html); NameValueCollection nvc = this.ToolWebSite.GetNameValueCollection(new string[] { "ctl00$ScriptManager1", "__EVENTTARGET", "__EVENTARGUMENT", "__VIEWSTATE", "ctl00$cph_context$KBQKGSList$ddlSearchType", "ctl00$cph_context$KBQKGSList$txtQymc", "ctl00$cph_context$KBQKGSList$GridViewPaging1$txtGridViewPagingForwardTo", "__VIEWSTATEENCRYPTED", "ctl00$cph_context$KBQKGSList$GridViewPaging1$btnNext.x", "ctl00$cph_context$KBQKGSList$GridViewPaging1$btnNext.y" }, new string[] { "ctl00$cph_context$KBQKGSList$UpdatePanel2|ctl00$cph_context$KBQKGSList$GridViewPaging1$btnNext", "", "", viewState, "A.Gcbh", "", (i - 1).ToString(), "", "5", "6" }); try { html = this.ToolWebSite.GetHtmlByUrl(this.SiteUrl, nvc, Encoding.UTF8, ref tempCookie); } catch { continue; } } parser = new Parser(new Lexer(html)); NodeList listNode = parser.ExtractAllNodesThatMatch(new AndFilter(new TagNameFilter("table"), new HasAttributeFilter("id", "ctl00_cph_context_KBQKGSList_GridView1"))); if (listNode != null && listNode.Count > 0) { TableTag table = listNode[0] as TableTag; for (int j = 1; j < table.RowCount; j++) { string code = string.Empty, prjName = string.Empty, PublicityEndDate = string.Empty, InfoUrl = string.Empty, msgType = string.Empty, ctx = string.Empty, HtmlTxt = string.Empty, beginDate = string.Empty; TableRow tr = table.Rows[j]; code = tr.Columns[1].ToNodePlainString(); prjName = tr.Columns[2].ToNodePlainString(); PublicityEndDate = tr.Columns[3].ToPlainTextString(); beginDate = DateTime.Now.ToString(); InfoUrl = "http://jyzx.cb.gov.cn/LGjyzxWeb/SiteManage/" + tr.Columns[4].GetATagHref(); string htmldtl = string.Empty; try { htmldtl = this.ToolWebSite.GetHtmlByUrl(InfoUrl, Encoding.UTF8, ref tempCookie).GetJsString(); } catch { continue; } parser = new Parser(new Lexer(htmldtl)); NodeList dtlNode = parser.ExtractAllNodesThatMatch(new AndFilter(new TagNameFilter("div"), new HasAttributeFilter("class", "listtable"))); if (dtlNode != null && dtlNode.Count > 0) { HtmlTxt = dtlNode.AsHtml(); ctx = HtmlTxt.ToCtxString(); msgType = "深圳市建设工程交易中心龙岗分中心"; BidSituation info = ToolDb.GetBidSituation("广东省", "深圳龙岗区工程", "龙岗区", code, prjName, PublicityEndDate, msgType, InfoUrl, ctx, HtmlTxt, beginDate); sqlCount++; if (!crawlAll && sqlCount >= this.MaxCount) { return(list); } if (ToolDb.SaveEntity(info, this.ExistCompareFields, this.ExistsUpdate, this.ExistsHtlCtx)) { if (this.ExistsUpdate) { object id = ToolDb.ExecuteScalar(string.Format("select Id from BidSituation where InfoUrl='{0}'", info.InfoUrl)); if (id != null) { string sql = string.Format("delete from BaseAttach where SourceID='{0}'", id); ToolDb.ExecuteSql(sql); } } parser = new Parser(new Lexer(HtmlTxt)); NodeList aNode = parser.ExtractAllNodesThatMatch(new TagNameFilter("a")); if (aNode != null && aNode.Count > 0) { for (int d = 0; d < aNode.Count; d++) { ATag aTag = aNode[0] as ATag; if (!aTag.IsAtagAttach()) { continue; } string url = "http://jyzx.cb.gov.cn/LGjyzxWeb/" + aTag.Link.Replace("../", ""); BaseAttach attach = null; try { attach = ToolHtml.GetBaseAttach(url, aTag.LinkText, info.Id, "SiteManage\\Files\\Attach\\"); if (attach == null) { attach = ToolHtml.GetBaseAttach(url, aTag.LinkText, info.Id, "SiteManage\\Files\\Attach\\"); } } catch { } if (attach != null) { ToolDb.SaveEntity(attach, string.Empty); } } } } } } } } return(list); }
protected override IList ExecuteCrawl(bool crawlAll) { IList list = new List <BidSituation>(); string html = string.Empty; string cookiestr = string.Empty; string viewState = string.Empty; int pageInt = 1, sqlCount = 0; string eventValidation = string.Empty; try { html = this.ToolWebSite.GetHtmlByUrl("http://www.szjsjy.com.cn/HomePage.aspx", Encoding.UTF8, ref cookiestr); viewState = this.ToolWebSite.GetAspNetViewState(html); eventValidation = this.ToolWebSite.GetAspNetEventValidation(html); NameValueCollection n = this.ToolWebSite.GetNameValueCollection( new string[] { "__VIEWSTATE", "__VIEWSTATEENCRYPTED", "__EVENTVALIDATION", "TextBox1", "ddl", "DDL_Govt", "DDL_Trade", "txtText", "hdnSN", "ImageButton2.x", "ImageButton2.y" }, new string[] { viewState, "", eventValidation, "请输入关键字", "0", "0", "0", "CN=年度施工投标人7,OU=1007,L=深圳市,ST=广东省,C=CN", "241EDFC1BA276AA7", "19", "13" } ); string tempCookie = string.Empty; html = this.ToolWebSite.GetHtmlByUrl("http://www.szjsjy.com.cn/HomePage.aspx", n , Encoding.UTF8, ref tempCookie); cookiestr = tempCookie.Replace("path=/;", "").Replace("HttpOnly,", "").Replace("HttpOnly", "").Replace(" ", ""); //"_gscu_485601283=265607704dljg167; _gscs_485601283=32711103yul0an14|pv:5;" + tempCookie.Replace("path=/;", "").Replace("HttpOnly,", "").Replace("HttpOnly", "").Replace(" ", ""); //tempCookie = tempCookie.Replace("path=/;", "").Replace("HttpOnly,", "").Replace("HttpOnly", "").Replace(" ", ""); html = this.ToolWebSite.GetHtmlByUrl(this.SiteUrl, Encoding.UTF8, ref cookiestr); } catch { return(list); } Parser parser = new Parser(new Lexer(html)); NodeList pageNode = parser.ExtractAllNodesThatMatch(new AndFilter(new TagNameFilter("table"), new HasAttributeFilter("id", "ctl00_Content_GridView1"))); if (pageNode != null && pageNode.Count > 0) { TableTag table = pageNode[0] as TableTag; try { string temp = table.Rows[table.RowCount - 1].ToNodePlainString().GetRegexBegEnd(",共", "页"); pageInt = int.Parse(temp); } catch { } } for (int i = 1; i <= pageInt; i++) { if (i > 1) { viewState = this.ToolWebSite.GetAspNetViewState(html); eventValidation = this.ToolWebSite.GetAspNetEventValidation(html); NameValueCollection nvc = this.ToolWebSite.GetNameValueCollection(new string[] { "__EVENTTARGET", "__EVENTARGUMENT", "__VIEWSTATE", "__VIEWSTATEENCRYPTED", "__EVENTVALIDATION", "ctl00$Content$drpSearchType", "ctl00$Content$txtQymc", "ctl00$Content$hdnOperate", "ctl00$hdnPageCount" }, new string[] { "ctl00$Content$GridView1", "Page$" + i, viewState, "", eventValidation, "0", "", "", pageInt.ToString() }); try { html = this.ToolWebSite.GetHtmlByUrl(this.SiteUrl, nvc, Encoding.UTF8, ref cookiestr); } catch { continue; } } parser = new Parser(new Lexer(html)); NodeList listNode = parser.ExtractAllNodesThatMatch(new AndFilter(new TagNameFilter("table"), new HasAttributeFilter("id", "ctl00_Content_GridView1"))); if (listNode != null && listNode.Count > 0) { TableTag table = listNode[0] as TableTag; for (int j = 1; j < table.RowCount - 1; j++) { string code = string.Empty, prjName = string.Empty, PublicityEndDate = string.Empty, InfoUrl = string.Empty, msgType = string.Empty, ctx = string.Empty, HtmlTxt = string.Empty, beginDate = string.Empty; TableRow tr = table.Rows[j]; code = tr.Columns[1].ToNodePlainString(); prjName = tr.Columns[2].ToNodePlainString(); PublicityEndDate = tr.Columns[3].ToPlainTextString(); beginDate = DateTime.Now.ToString(); InfoUrl = "http://www.szjsjy.com.cn/BusinessInfo/" + tr.Columns[4].GetATagHref(); string htmldtl = string.Empty; try { htmldtl = this.ToolWebSite.GetHtmlByUrl(InfoUrl, Encoding.UTF8, ref cookiestr).GetJsString(); } catch { continue; } parser = new Parser(new Lexer(htmldtl)); NodeList dtlNode = parser.ExtractAllNodesThatMatch(new AndFilter(new TagNameFilter("div"), new HasAttributeFilter("class", "ContentContainer"))); if (dtlNode != null && dtlNode.Count > 0) { HtmlTxt = dtlNode.AsHtml(); ctx = HtmlTxt.ToCtxString(); msgType = "深圳市建设工程交易中心"; BidSituation info = ToolDb.GetBidSituation("广东省", "深圳市工程", "", code, prjName, PublicityEndDate, msgType, InfoUrl, ctx, HtmlTxt, beginDate); sqlCount++; if (!crawlAll && sqlCount >= this.MaxCount) { return(list); } if (ToolDb.SaveEntity(info, this.ExistCompareFields, this.ExistsUpdate, this.ExistsHtlCtx)) { parser = new Parser(new Lexer(HtmlTxt)); NodeList aNode = parser.ExtractAllNodesThatMatch(new TagNameFilter("a")); if (aNode != null && aNode.Count > 0) { for (int d = 0; d < aNode.Count; d++) { ATag aTag = aNode[0] as ATag; if (!aTag.IsAtagAttach()) { continue; } string url = "http://www.szjsjy.com.cn/" + aTag.Link.Replace("../", ""); BaseAttach attach = null; try { attach = ToolHtml.GetBaseAttach(url, aTag.LinkText, info.Id, "SiteManage\\Files\\Attach\\"); if (attach == null) { attach = ToolHtml.GetBaseAttach(url, aTag.LinkText, info.Id, "SiteManage\\Files\\Attach\\"); } } catch { } if (attach != null) { ToolDb.SaveEntity(attach, string.Empty); } } } } } } } } return(list); }
protected override IList ExecuteCrawl(bool crawlAll) { IList list = new List <BidSituation>(); int sqlCount = 0; string html = string.Empty; try { html = this.ToolWebSite.GetHtmlByUrl("https://www.szjsjy.com.cn:8001/jyw/queryKBJiLuList.do?page=1&rows=" + this.MaxCount); } catch { return(null); } int startIndex = html.IndexOf("{"); int endIndex = html.LastIndexOf("}"); html = html.Substring(startIndex, (endIndex + 1) - startIndex); JavaScriptSerializer serializer = new JavaScriptSerializer(); Dictionary <string, object> smsTypeJson = (Dictionary <string, object>)serializer.DeserializeObject(html); foreach (KeyValuePair <string, object> obj in smsTypeJson) { if (obj.Key == "total") { continue; } object[] array = (object[])obj.Value; foreach (object arrValue in array) { string code = string.Empty, prjName = string.Empty, PublicityEndDate = string.Empty, InfoUrl = string.Empty, msgType = string.Empty, ctx = string.Empty, HtmlTxt = string.Empty, beginDate = string.Empty; Dictionary <string, object> dic = (Dictionary <string, object>)arrValue; code = Convert.ToString(dic["bdBH"]); prjName = Convert.ToString(dic["bdName"]); // if (!prjName.Contains("2016年交通拥堵综合治理(玉昌东路、炮台路、楼明路)项目施工")) continue; beginDate = Convert.ToString(dic["faBuTime2"]); InfoUrl = "https://www.szjsjy.com.cn:8001/jyw/queryOldDataDetail.do?type=5&id=" + code;// Convert.ToString(dic["bdGuid"]); bool isJson = false; string attachFileGroupGuid = string.Empty; string rwfileGuid = string.Empty; try { HtmlTxt = this.ToolWebSite.GetHtmlByUrl(InfoUrl).GetJsString().GetReplace("\\t,\\r,\\n,\""); if (string.IsNullOrEmpty(HtmlTxt)) { string kbJiLuGuid = dic["kbJiLuGuid"].ToString(); string ggGuid = string.Empty; string bdGuid = dic["bdGuid"].ToString(); string url = "https://www.szjsjy.com.cn:8001/jyw/querykbJiLuDetail.do?kbJiLuGuid=" + kbJiLuGuid + "&ggGuid=" + ggGuid + "&bdGuid=" + bdGuid; isJson = true; HtmlTxt = this.ToolWebSite.GetHtmlByUrl(url); } } catch (Exception ex) { Logger.Error(prjName); Logger.Error(ex); continue; } if (!isJson) { ctx = HtmlTxt.ToCtxString(); } else { try { JavaScriptSerializer newSerializer = new JavaScriptSerializer(); Dictionary <string, object> newTypeJson = (Dictionary <string, object>)newSerializer.DeserializeObject(HtmlTxt); Dictionary <string, object> kbJiLu = newTypeJson["kbJiLu"] as Dictionary <string, object>; Dictionary <string, object> ggBD = kbJiLu["ggBD"] as Dictionary <string, object>; Dictionary <string, object> bd = ggBD["bd"] as Dictionary <string, object>; attachFileGroupGuid = Convert.ToString(kbJiLu["attachFileGroupGuid"]); rwfileGuid = Convert.ToString(kbJiLu["rwfileGuid"]); string bdBH = Convert.ToString(bd["bdBH"]); string bdName = Convert.ToString(bd["bdName"]); string gcLeiXing = Convert.ToString(bd["gcLeiXing"]); //string jieZhiTime = Convert.ToString(bd["jieZhiTime"]); ctx = "标段编号:" + bdBH + "\r\n" + "标段名称:" + bdName; HtmlTxt = "标段编号:" + bdBH + "</br>" + "标段名称:" + bdName; } catch (Exception ex) { Logger.Error(ex); } } msgType = "深圳市建设工程交易中心"; string saveUrl = Convert.ToString(dic["detailUrl"]); BidSituation info = ToolDb.GetBidSituation("广东省", "深圳市工程", "", code, prjName, PublicityEndDate, msgType, saveUrl, ctx, HtmlTxt, beginDate); sqlCount++; if (!crawlAll && sqlCount >= this.MaxCount) { return(list); } if (ToolDb.SaveEntity(info, this.ExistCompareFields, this.ExistsUpdate, this.ExistsHtlCtx)) { if (this.ExistsUpdate) { object id = ToolDb.ExecuteScalar(string.Format("select Id from BidSituation where InfoUrl='{0}'", info.InfoUrl)); if (id != null) { string sql = string.Format("delete from BaseAttach where SourceID='{0}'", id); ToolDb.ExecuteSql(sql); } } if (isJson) { BaseAttach attach = null; BaseAttach rwattach = null; try { string url = "https://www.szjsjy.com.cn:8001/jyw/filegroup/queryByGroupGuidZS.do?groupGuid=" + attachFileGroupGuid; string attachHtml = this.ToolWebSite.GetHtmlByUrl(url); JavaScriptSerializer newSerializer = new JavaScriptSerializer(); Dictionary <string, object> newTypeJson = (Dictionary <string, object>)newSerializer.DeserializeObject(attachHtml); string attachGuid = string.Empty; foreach (KeyValuePair <string, object> newObj in newTypeJson) { object[] newArray = (object[])newObj.Value; foreach (object newArr in newArray) { Dictionary <string, object> newDic = (Dictionary <string, object>)newArr; try { attachGuid = Convert.ToString(newDic["attachGuid"]); break; } catch { continue; } } break; } string newUrl = "https://www.szjsjy.com.cn:8001/file/downloadFile?fileId=" + attachGuid; //https://www.szjsjy.com.cn:8001/file/downloadFile?fileId=191b3e99-9ca8-4e7e-8939-87b322f5e094 attach = ToolHtml.GetBaseAttach(newUrl, "开标情况一览表.pdf", info.Id, "SiteManage\\Files\\Attach\\"); if (attach == null) { attach = ToolHtml.GetBaseAttach(newUrl, "开标情况一览表.pdf", info.Id, "SiteManage\\Files\\Attach\\"); } } catch { } if (attach != null) { ToolDb.SaveEntity(attach, string.Empty); } if (rwfileGuid != "") { try { string url = "https://www.szjsjy.com.cn:8001/jyw/filegroup/queryByGroupGuidZS.do?groupGuid=" + rwfileGuid; string rwattachHtml = this.ToolWebSite.GetHtmlByUrl(url); JavaScriptSerializer rwnewSerializer = new JavaScriptSerializer(); Dictionary <string, object> rwnewTypeJson = (Dictionary <string, object>)rwnewSerializer.DeserializeObject(rwattachHtml); string rwattachGuid = string.Empty; foreach (KeyValuePair <string, object> newObj in rwnewTypeJson) { object[] rwnewArray = (object[])newObj.Value; foreach (object newArr in rwnewArray) { Dictionary <string, object> rwnewDic = (Dictionary <string, object>)newArr; try { rwattachGuid = Convert.ToString(rwnewDic["attachGuid"]); break; } catch { continue; } } break; } string newUrl = "https://www.szjsjy.com.cn:8001/file/downloadFile?fileId=" + rwattachGuid; //https://www.szjsjy.com.cn:8001/file/downloadFile?fileId=191b3e99-9ca8-4e7e-8939-87b322f5e094 rwattach = ToolHtml.GetBaseAttach(newUrl, "入围结果表.pdf", info.Id, "SiteManage\\Files\\Attach\\"); if (rwattach == null) { rwattach = ToolHtml.GetBaseAttach(newUrl, "入围结果表.pdf", info.Id, "SiteManage\\Files\\Attach\\"); } } catch { } if (rwattach != null) { ToolDb.SaveEntity(rwattach, string.Empty); } } } else { Parser parser = new Parser(new Lexer(HtmlTxt)); NodeList aNode = parser.ExtractAllNodesThatMatch(new TagNameFilter("a")); if (aNode != null && aNode.Count > 0) { for (int d = 0; d < aNode.Count; d++) { ATag aTag = aNode[0] as ATag; if (!aTag.IsAtagAttach()) { continue; } string url = string.Empty; if (!aTag.Link.ToLower().Contains("http")) { url = "http://www.szjsjy.com.cn/" + aTag.Link.GetReplace("../,\\"); } else { url = aTag.Link.GetReplace("\\"); } BaseAttach attach = null; try { attach = ToolHtml.GetBaseAttach(url, aTag.LinkText, info.Id, "SiteManage\\Files\\Attach\\"); if (attach == null) { attach = ToolHtml.GetBaseAttach(url, aTag.LinkText, info.Id, "SiteManage\\Files\\Attach\\"); } } catch { } if (attach != null) { ToolDb.SaveEntity(attach, string.Empty); } } } } } } } return(list); }