private void GetYearPageInfo(IListSheet listSheet) { string sourceDir = this.RunPage.GetDetailSourceFileDir(); ExcelWriter resultEW = this.CreateResultWriter(); for (int i = 0; i < listSheet.RowCount; i++) { Dictionary <string, string> listRow = listSheet.GetRow(i); string yearValue = listRow["yearValue"]; string yearName = listRow["yearName"]; string pageUrl = listRow[SysConfig.DetailPageUrlFieldName]; HtmlAgilityPack.HtmlDocument htmlDoc = this.RunPage.GetLocalHtmlDocument(listSheet, i); HtmlNodeCollection pNodes = htmlDoc.DocumentNode.SelectNodes("//span[@class=\"table2\"]/p"); StringBuilder textInfo = new StringBuilder(); if (pNodes == null || pNodes.Count == 0) { string errorInfo = "未查询到" + yearValue + "年的事件内容"; this.RunPage.InvokeAppendLogText(errorInfo, LogLevelType.Error, true); } else { bool startText = false; foreach (HtmlNode pNode in pNodes) { string pText = CommonUtil.HtmlDecode(pNode.InnerText).Trim(); if (startText) { textInfo.AppendLine(pText); } else if (pText == "大事記") { startText = true; } } string eventText = textInfo.ToString(); string eventTextSimple1 = CharProcessor.ConverterChinese(eventText, ChineseConversionDirection.TraditionalToSimplified); string eventTextSimple2 = Microsoft.VisualBasic.Strings.StrConv(eventText, Microsoft.VisualBasic.VbStrConv.SimplifiedChinese, 0); Dictionary <string, string> resultRow = new Dictionary <string, string>(); resultRow.Add("url", pageUrl); resultRow.Add("yearName", yearName); resultRow.Add("yearValue", yearValue); resultRow.Add("eventText", eventText); resultRow.Add("eventTextSimple1", eventTextSimple1); resultRow.Add("eventTextSimple2", eventTextSimple2); resultEW.AddRow(resultRow); } } resultEW.SaveToDisk(); }
public objectReader(Action <DataItem> done, CharProcessor next) { _done = done; _nextProcessor = next; }
public valueReader(Action <string, object> done, CharProcessor next) { _done = done; _next = next; }
public arrayReader(Action <DataList> done, CharProcessor next) { _done = done; _next = next; }