protected string SaveFinalPageContent(string strMainDateRules, string strMainContentElementRules, string strVisitUrl, string strReturnPage) { string strRet = ""; string strMainContent = ""; HtmlAgilityPack.HtmlDocument htmlDoc = GetHtmlDocument(strReturnPage); if (htmlDoc == null) { return("下载失败!"); } IEnumerable <HtmlNode> NodesMainContent = htmlDoc.DocumentNode.QuerySelectorAll(strMainContentElementRules); if (NodesMainContent.Count() > 0) { strMainContent = NodesMainContent.ToArray()[0].InnerHtml; string strTitle = m_dicUrl2Title[strVisitUrl]; DelegatePara dp = new DelegatePara(); dp.strTitle = strTitle; dp.strContent = strMainContent; delAddBlog(dp); } return(strRet); }
private void AddBlog(BlogGather.DelegatePara dp) { if (this.InvokeRequired) { this.Invoke(new BlogGatherCnblogs.GreetingDelegate(this.AddBlog), dp); return; } DataRow row1 = m_ataTable.NewRow(); row1["标题"] = dp.strTitle; row1["内容"] = dp.strContent; m_ataTable.Rows.Add(row1); this.dataGridView1.DataSource = m_ataTable; this.dataGridView1.Columns[1].Visible = false; this.dataGridView1.Columns[0].Width = this.Width; }
private void AddBlog(BlogGather.DelegatePara dp) { if (this.InvokeRequired) { this.Invoke(new BlogGatherCnblogs.GreetingDelegate(this.AddBlog), dp); return; } try { string strWholeDbName = m_strDBConStringPath + this.toolStripTextBox1.Text + ".db"; DYH_DB.Model.AU_LayerNode modelAU_LayerNode = new DYH_DB.Model.AU_LayerNode(); modelAU_LayerNode.AU_ParentLayerNodeID = -1; modelAU_LayerNode.AU_LayerNodeID = m_bllAU_LayerNode.GetMaxId(strWholeDbName); modelAU_LayerNode.AU_UrlLayer = 0; modelAU_LayerNode.AU_UrlAddress = ""; string strTitle = Regex.Replace(dp.strTitle, @"[|/\;.':*?<>-]", "").ToString(); strTitle = Regex.Replace(strTitle, "[\"]", "").ToString(); strTitle = Regex.Replace(strTitle, @"\s", ""); modelAU_LayerNode.AU_UrlTitle = strTitle; modelAU_LayerNode.AU_UrlContent = dp.strContent;; modelAU_LayerNode.AU_IsVisit = 0; modelAU_LayerNode.AU_RemoveSameOffset1 = 0; modelAU_LayerNode.AU_RemoveSameOffset2 = 0; modelAU_LayerNode.AU_LastUpdateDate = System.DateTime.Now.Date; m_bllAU_LayerNode.Add(strWholeDbName, modelAU_LayerNode); DataSet dsTemps = m_bllAU_LayerNode.GetList(strWholeDbName, ""); this.dataGridView1.DataSource = dsTemps.Tables[0]; this.dataGridView1.Columns[1].Visible = false; this.dataGridView1.Columns[0].Width = this.Width; } catch (Exception ex) { } }