public List <ArtMovie> GetVideoPage(int page) { List <ArtMovie> HegreVideos = new List <ArtMovie>(); HtmlAgilityPack.HtmlDocument doc = hw.Load("http://hegre-art.com/films?films_page=" + page.ToString()); var nodes = doc.DocumentNode.SelectNodes("//div[@class='item']"); if (nodes == null) { return(HegreVideos); } foreach (var item in nodes) { var title = item.SelectSingleNode("./div/a").Attributes["title"].Value.ToString().Trim(); var link = "http://www.hegre-art.com" + item.SelectSingleNode("./div/a").Attributes["href"].Value.ToString().Trim(); var coverPicUrl = item.SelectSingleNode(".//div[@class='cover-links']/a[1]").Attributes["href"].Value.ToString().Trim(); var boardPicUrl = item.SelectSingleNode(".//div[@class='cover-links']/a[2]").Attributes["href"].Value.ToString().Trim(); ArtMovie m = new ArtMovie() { Title = title, Url = link, Type = "Videos", CoverLink = coverPicUrl, CoverLink2 = boardPicUrl }; if (this.IsDownloadCoverPicture) { if (this.cp == null) { this.cp = new CoverProcessor("VideoHegreCovers"); } m.CoverFile = cp.save(coverPicUrl, title + ".jpg"); } if (this.IsDownloadExtraPicture) { if (this.cp == null) { this.cp = new CoverProcessor("VideoHegreCovers"); } m.CoverFile2 = cp.save(boardPicUrl, title + "_Board.jpg"); } OnCompleteOneItem(m); HegreVideos.Add(m); } return(HegreVideos); }
public List <ArtMovie> GetAllUpdate(int p) { var html = wc.DownloadString("http://www.x-art.com/index.php?show=galleries&pref=items&page=" + p + "&catname=all&order=recent"); string[] sep = new string[] { "<!--------------------------------------- ITEM -->", "<!--------------------------------------- finItem -->" }; var itemHtml = html.Split(sep, StringSplitOptions.RemoveEmptyEntries); List <string> item12 = new List <string>(); for (int i = 0; i < itemHtml.Length; i++) { itemHtml[i] = itemHtml[i].Replace("\\n", ""); itemHtml[i] = itemHtml[i].Replace("\\", ""); itemHtml[i] = itemHtml[i].Trim(); if (itemHtml[i] != "") { item12.Add(itemHtml[i]); } } HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument(); List <ArtMovie> list = new List <ArtMovie>(); for (int i = 1; i < item12.Count - 1; i++) { doc.LoadHtml(item12[i]); var title = doc.DocumentNode.SelectSingleNode("//h1").InnerText; //var desc = item.SelectSingleNode(".//p").InnerText; var descNullable = doc.DocumentNode.SelectSingleNode("//p"); string desc = ""; if (descNullable != null) { desc = descNullable.InnerText; } var linker = doc.DocumentNode.SelectSingleNode("//a").Attributes["href"].Value; var image = doc.DocumentNode.SelectSingleNode("//img").Attributes[0].Value; System.Text.RegularExpressions.Regex reg = new System.Text.RegularExpressions.Regex("http://.*?jpg"); var matches = reg.Matches(image); if (matches.Count > 0) { image = matches[0].ToString(); } var publishDate = doc.DocumentNode.SelectSingleNode("//h2").InnerText.Trim(); var tpe = doc.DocumentNode.SelectSingleNode("//h2[1]").InnerText.Trim(); ArtMovie m = new ArtMovie() { Title = title, Url = linker, Description = desc, CoverLink = image, PublishDate = publishDate, Type = tpe }; if (this._isNeedDownloadCover) { if (this.cp == null) { this.cp = new CoverProcessor("Covers"); } m.CoverFile = cp.save(image, title + ".jpg"); } OnCompleteOneItem(m); list.Add(m); } return(list); }
public List <ArtModel> GetAllModels() { var urlModel = "http://www.x-art.com/index.php?show=model&pref=items&page=######&order=recent&catname="; List <ArtModel> list = new List <ArtModel>(); var sep = new string[] { "<!--------------------------------------- ITEM -->", "<!--------------------------------------- finItem -->" }; HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument(); for (int i = 1; i < 13; i++) { var u = urlModel.Replace("######", i.ToString()); var html = wc.DownloadString(u); var itemHtml = html.Split(sep, StringSplitOptions.RemoveEmptyEntries); List <string> items = new List <string>(); Console.WriteLine(itemHtml.Length + " html分段"); for (int j = 0; j < itemHtml.Length; j++) { itemHtml[j] = itemHtml[j].Trim().Replace("\\n", ""); itemHtml[j] = itemHtml[j].Trim().Replace("\\r", ""); itemHtml[j] = itemHtml[j].Replace("\\", ""); itemHtml[j] = itemHtml[j].Trim(); if (itemHtml[j] != "") { items.Add(itemHtml[j]); } } for (int k = 1; k < items.Count; k++) { doc.LoadHtml(items[k]); if (doc.DocumentNode.SelectSingleNode("//h1") == null) { continue; } var name = doc.DocumentNode.SelectSingleNode("//h1").InnerText; var country = doc.DocumentNode.SelectNodes("//h2")[1].InnerText; var age = doc.DocumentNode.SelectSingleNode("//h2").InnerText; var rate = ""; var url = doc.DocumentNode.SelectSingleNode("//a").Attributes["href"].Value; var picturnUrl = doc.DocumentNode.SelectSingleNode("//img").Attributes["src"].Value; ArtModel mo = new ArtModel() { Name = name, Age = age, Country = country, Rate = rate, PictrueUrl = picturnUrl, ModelURL = url }; if (this._isNeedDownloadCover) { if (this.cp == null) { this.cp = new CoverProcessor("Models"); } mo.PictureFile = cp.save(mo.PictrueUrl, name + ".jpg"); } OnCompleteOneItem(mo); list.Add(mo); } } return(list); }
public List <ArtMovie> GetPicturePage(int page) { List <ArtMovie> HegreGalleries = new List <ArtMovie>(); HtmlAgilityPack.HtmlDocument doc = hw.Load("http://www.hegre-art.com/galleries?galleries_page=" + page.ToString()); var nodes = doc.DocumentNode.SelectNodes("//div[@class='item']"); if (nodes == null) { return(HegreGalleries); } foreach (var item in nodes) { var title = item.SelectSingleNode(".//h4").InnerText.Trim(); title = title.Substring(title.IndexOf("\t\t\t\t\t\t")).Trim(); string date; try { date = item.SelectSingleNode(".//h4/small").InnerText.Trim(); } catch { date = ""; } string link; try { link = "http://www.hegre-art.com" + item.SelectSingleNode("./div/a").Attributes["href"].Value.ToString().Trim(); } catch (Exception) { link = ""; } string coverPicURL; try { coverPicURL = item.SelectSingleNode(".//div[@class='cover-links']/a[1]").Attributes["href"].Value.ToString().Trim(); } catch { coverPicURL = ""; } string boardPicURL; try { boardPicURL = item.SelectSingleNode(".//div[@class='cover-links']/a[2]").Attributes["href"].Value.ToString().Trim(); } catch { boardPicURL = ""; } ArtMovie m = new ArtMovie() { Title = title, Url = link, Type = "Images", CoverLink = coverPicURL, CoverLink2 = boardPicURL }; if (this.IsDownloadCoverPicture) { if (this.cp == null) { this.cp = new CoverProcessor("HegreCovers"); } m.CoverFile = cp.save(coverPicURL, title + ".jpg"); } if (this.IsDownloadExtraPicture) { if (this.cp == null) { this.cp = new CoverProcessor("HegreCovers"); } m.CoverFile2 = cp.save(boardPicURL, title + "_Board.jpg"); } OnCompleteOneItem(m); HegreGalleries.Add(m); } return(HegreGalleries); }