//根据页面链接获取页面的资源下的信息 详细信息,即名称和下载链接,介绍等 public static void GetResoucePageInfo(tb_resoucepageslist respageListModel) { //string xpath =@"td[1]/a[1] "; //属性 ed2k HtmlDocument doc = CaptureWebSite.GetHtmlDocument (respageListModel.PageURL ,VerycdEncoding ) ; HtmlNodeCollection hc = doc.DocumentNode.SelectNodes ("//@ed2k") ; respageListModel.CollectionMark = 1 ; respageListModel.Update () ; for (int i = 0; i <hc.Count ; i++) { try { tb_resoucelink model = new tb_resoucelink () ; string name = hc[i ].Attributes["ed2k"].Value.Trim (); string urlLink = HttpUtility.UrlDecode (name,Encoding.UTF8 ) ; model.ResouceMD5 = urlLink.Split('|')[4] ; model.ResouceName = urlLink.Split('|')[2] ; model.ResouceLink = urlLink ; model.FromURL = respageListModel.PageURL ; model.ClassName = respageListModel .ClassName ; model.SubClassName = respageListModel .SubClassName ; model.InfoOrigin = "VeryCd" ; model.Remark = string.Empty ; model.ResouceType = respageListModel.ResouceType ; model.UpdateTime = DateTime.Now ; model.Save () ; } catch (Exception err) { continue ; } } respageListModel.CollectionMark = 2 ; respageListModel.Update () ; Console.WriteLine (respageListModel.PageURL ) ; }
//根据页面链接获取页面的资源下的信息 详细信息,即名称和下载链接,介绍等 public static void GetResoucePageInfo(tb_resoucepageslist respageListModel) { if (respageListModel.CollectionMark == 2) return; HtmlDocument doc = CaptureWebSite.GetHtmlDocument(respageListModel.PageURL, VerycdEncoding); HtmlNodeCollection hc = doc.DocumentNode.SelectNodes("//@ed2k"); respageListModel.CollectionMark = 1; respageListModel.Update(); int count = 0; try { for (int i = 0; i < hc.Count; i++) { string name = hc[i].Attributes["ed2k"].Value.Trim(); string urlLink = HttpUtility.UrlDecode(name, Encoding.UTF8); string[] linkFields = urlLink.Split('|'); if (tb_resoucelink.FindCount(tb_resoucelink._.ResouceMD5, linkFields[4]) < 1) { tb_resoucelink model = new tb_resoucelink(); model.ResouceMD5 = linkFields[4]; model.ResouceName = linkFields[2]; long size; if (long.TryParse(linkFields[3], out size)) model.Size = (ulong)size; else model.Size = 0; model.ResouceLink = urlLink; model.FromURL = respageListModel.PageURL; model.ClassName = respageListModel.ClassName; model.SubClassName = respageListModel.SubClassName; model.InfoOrigin = "VeryCd"; model.Remark = string.Empty; model.ResouceType = respageListModel.ResouceType; model.UpdateTime = DateTime.Now; model.IsDownload = 0; model.Insert(); count++; } } } catch (Exception err) { XTrace.WriteException(err); } finally { respageListModel.CollectionMark = 2; respageListModel.Update(); XTrace.WriteLine("从资源页面{0}获取到{1}条新的资源链接", respageListModel.PageURL, count); } }