//根据资源集合列表网址获取单独资源的列表 public static void GetPageResouceList(tb_fistclasslist firClassListModel) { HtmlDocument doc = CaptureWebSite.GetHtmlDocument (firClassListModel.WebURL ,VerycdEncoding ) ; HtmlNodeCollection hc = doc.DocumentNode.SelectNodes (xPath_ResouceList ) ; firClassListModel.CollectionMark = 1 ; firClassListModel.Update () ; for (int i = 0; i < hc.Count ; i++) { try { tb_resoucepageslist model = new tb_resoucepageslist () ; model.PageURL =(verycdWebSite + hc[i].SelectSingleNode (@"a[1]").Attributes["href"].Value.Trim ()) ; model.PageTitle = hc[i].InnerText.Trim () ; model.ClassName = firClassListModel.ClassName ; model.SubClassName = firClassListModel.SubClassName ; model.CollectionMark = 0 ; model.InfoOrigin = "VeryCd" ; model.Remark = string.Empty ; model.ResouceType = firClassListModel.ResouceType ; model.UpdateTime = DateTime.Now ; model.Save () ; } catch (Exception err) { continue ; } finally { firClassListModel.CollectionMark = 2 ; firClassListModel.Update () ; } } }
//根据资源集合列表网址获取单独资源的列表 public static void GetPageResouceList(tb_fistclasslist firClassListModel) { //传入进来的都是可以操作的 if (firClassListModel.CollectionMark == 2) return;//采集过的不再重复进行 HtmlDocument doc = CaptureWebSite.GetHtmlDocument(firClassListModel.WebURL, VerycdEncoding); HtmlNodeCollection hc = doc.DocumentNode.SelectNodes(xPath_ResouceList); firClassListModel.CollectionMark = 1; firClassListModel.Update(); int count = 0; try { for (int i = 0; i < hc.Count; i++) { string url = (verycdWebSite + hc[i].SelectSingleNode(@"a[1]").Attributes["href"].Value.Trim()); if (tb_resoucepageslist.FindCount(tb_resoucepageslist._.PageURL, url) < 1) { tb_resoucepageslist model = new tb_resoucepageslist(); model.PageURL = url; model.PageTitle = hc[i].InnerText.Trim(); model.ClassName = firClassListModel.ClassName; model.SubClassName = firClassListModel.SubClassName; model.CollectionMark = 0; model.InfoOrigin = "VeryCd"; model.Remark = string.Empty; model.ResouceType = firClassListModel.ResouceType; model.UpdateTime = DateTime.Now; model.Insert(); count++; } } } catch (Exception err) { XTrace.WriteException(err); } finally { firClassListModel.CollectionMark = 2; firClassListModel.Update(); XTrace.WriteLine("通过大类资源列表页面:{0},获取到更新记录{1}条", firClassListModel.WebURL, count); } }