static void Main(string[] args) { string url = @"http://www.1pondo.tv/static-seo/sitemap-videos.xml"; UserAgent agent = new UserAgent("hoge", 1, "*****@*****.**", DefaultAgents.Firefox14); var reader = new HtmlReader(url, true, agent); var xml = reader.Html; XNamespace ns = reader.Namespace; XNamespace video = reader.Html.Root.Attribute(XNamespace.Xmlns + "video").Value; var list = xml.Descendants(video + "content_loc").Where(a => a.Value.Contains("092615_161")); var item = list.First().Ancestors(ns + "url"); var vitem = list.First().Ancestors(video + "video"); }
public override TagInfo GetItem(string searchWord) { try { TagInfo info = TagInfo.New(); HtmlReader reader = new HtmlReader(GetPageUrl(searchWord)); XDocument xml = reader.Html; XNamespace ns = reader.Namespace; // タイトル var title = xml.Descendant(ns + "h1", new XAttribute("class", "item fn")); info.Title = (title.HasElements) ? (title.LastNode as XElement).Value.Trim() : title.Value.Trim(); // キャスト var casts = xml.Descendant(ns + "span", new XAttribute("id", "performer")); info.Casts = (xml.ToString().Contains("出演者:")) && casts != null ? casts.Descendants(ns + "a").Select(a => a.Value).ToArray() : new string[0]; // シリーズ info.Series = (xml.ToString().Contains("シリーズ:")) ? xml.Descendant(ns + "td", "シリーズ:").NextElement().Value : string.Empty; // メーカー if (xml.ToString().Contains("メーカー:")) { info.Makers = xml.Descendant(ns + "td", "メーカー:").NextElement().Descendants(ns + "a").Select(a => a.Value).ToArray(); } else if (xml.ToString().Contains("サークル名:")) { info.Makers = xml.Descendant(ns + "td", "サークル名:").NextElement().Descendants(ns + "a").Select(a => a.Value).ToArray(); } else { info.Makers = new string[0]; } // レーベル info.Labels = (xml.ToString().Contains("レーベル:")) ? xml.Descendant(ns + "td", "レーベル:").NextElement().Descendants(ns + "a").Select(a => a.Value).ToArray() : new string[0]; // ジャンル info.Genres = (xml.ToString().Contains("ジャンル:")) ? xml.Descendant(ns + "td", "ジャンル:").NextElement().Descendants(ns + "a").Select(a => a.Value).ToArray() : new string[0]; // コメント var comment = xml.Descendant(ns + "p", new XAttribute("class", "mg-b20")); info.Comment = (comment != null) ? comment.Value.Replace("\n", "").Replace("\r", "") : string.Empty; if (xml.ToString().Contains("品番:")) { // CenAvId info.CenAvId = xml.Descendant(ns + "td", "品番:").NextElement().Value; // Number info.Number = Convert.ToUInt32(Regex.Match(info.CenAvId, @".*[a-zA-Z]+([0-9]+)[a-zA-Z]*$").Groups[1].Value); } // イメージ var image = xml.Descendant(ns + "a", new XAttribute("name", "package-image")); string imageUrl = (image != null) ? image.Attribute("href").Value : xml.Descendant(ns + "img", new XAttribute("class", "tdmm")).Attribute("src").Value; using (WebClient client = new WebClient()) { using (MemoryStream stream = new MemoryStream(client.DownloadData(imageUrl))) { info.Pictures = new IPicture[]{ new Picture() { Type = PictureType.FrontCover, MimeType = "image/jpeg", Description = "Cover", Data = ByteVector.FromStream(stream) } }; } } info.Images = ((Func<BitmapSource[]>)(() => { ImageConverter ic = new ImageConverter(); return info.Pictures.Select( p => (ic.ConvertFrom(p.Data.Data) as Bitmap).ToWPFBitmap()).ToArray(); }))(); info.IsEmpty = false; return info; } catch (Exception ex) { throw new ApplicationException("アイテム要素が見つかりませんでした。", ex); } }
private string GetPageUrl(string searchWord) { string url = @"http://www.dmm.co.jp/search/=/searchstr=" + searchWord; try { HtmlReader reader = new HtmlReader(url); XDocument xml = reader.Html; XNamespace ns = reader.Namespace; var ditem = xml.Descendant(ns + "div", new XAttribute("class", "d-item")) .Descendants(ns + "li") .Where(a => !a.ToString().Contains("【数量限定】")) .Where(a => !a.ToString().Contains("【アウトレット】")) .Where(a => !a.ToString().Contains("【DMM限定】")) .Where(a => !a.ToString().Contains("Blu-ray")) .Where(a => !a.ToString().Contains("近日")) .Where(a => !a.ToString().Contains("10円動画")) .First(); return ditem.Descendants(ns + "a", "href").First().Attribute("href").Value; } catch (Exception ex) { throw new ApplicationException("ページが見つかりませんでした。", ex); } }
public override TagInfo GetItem(string searchWord) { try { TagInfo info = TagInfo.New(); HtmlReader reader = new HtmlReader("http://www.heyzo.com/moviepages/" + searchWord + "/index.html"); XDocument xml = reader.Html; XNamespace ns = reader.Namespace; var movie = xml.Descendant(ns + "div", new XAttribute("id", "movie")); // タイトル info.Title = string.Join(" - ", movie.Descendants("h1").First().Value.Split('-').Select(a => a.Trim())); // キャスト XElement cast = movie.Descendant(ns + "span", new XAttribute("class", "actor")).NextElement(); info.Casts = (cast != null) ? cast.Descendants(ns + "a").Select(a => a.Value).ToArray() : new string[0]; // シリーズ XElement series = movie.Descendant(ns + "span", new XAttribute("class", "label")).NextElement(); info.Series = (series != null) ? series.Value.Trim() : string.Empty; // メーカー info.Makers = new string[] { "HEYZO" }; // レーベル info.Labels = new string[0]; // ジャンル XElement genres = movie.Descendant(ns + "div", new XAttribute("class", "tagkeyword")); info.Genres = (genres != null) ? genres.Descendants(ns + "li").Select(a => a.Value).ToArray() : new string[0]; // コメント XElement comment = movie.Descendant(ns + "p", new XAttribute("class", "memo")); info.Comment = (comment != null) ? comment.FirstNode.ToString() : string.Empty; // CenAvId info.CenAvId = "HEYZO" + searchWord; // Number info.Number = Convert.ToUInt32(searchWord); // イメージ string imageUrl = "http://www.heyzo.com/contents/3000/" + searchWord + "/images/player_thumbnail.jpg"; using (WebClient client = new WebClient()) { using (MemoryStream stream = new MemoryStream(client.DownloadData(imageUrl))) { info.Pictures = new IPicture[]{ new Picture() { Type = PictureType.FrontCover, MimeType = "image/jpeg", Description = "Cover", Data = ByteVector.FromStream(stream) } }; } } info.Images = ((Func<BitmapSource[]>)(() => { ImageConverter ic = new ImageConverter(); return info.Pictures.Select( p => (ic.ConvertFrom(p.Data.Data) as Bitmap).ToWPFBitmap()).ToArray(); }))(); info.IsEmpty = false; return info; } catch (Exception ex) { throw new ApplicationException("アイテム要素が見つかりませんでした。", ex); } }
private string GetPageUrl(string searchWord) { string url = @"http://www.aventertainments.com/search_Products.aspx?languageID=2&dept_id=29&keyword=" + searchWord + "&searchby=keyword"; try { HtmlReader reader = new HtmlReader(url, agent: ua, encoding: Encoding.UTF8); XDocument xml = reader.Html; XNamespace ns = reader.Namespace; var table = xml.Descendant(ns + "table", new XAttribute("id", "ctl00_ContentPlaceHolder1_Rows2Items1_MyList")); return table.Descendants(ns + "a", "href").First().Attribute("href").Value; } catch (Exception ex) { throw new ApplicationException("ページが見つかりませんでした。", ex); } }
public override TagInfo GetItem(string searchWord) { try { TagInfo info = TagInfo.New(); HtmlReader reader = new HtmlReader(GetPageUrl(searchWord), agent: ua, encoding: Encoding.UTF8); XDocument xml = reader.Html; XNamespace ns = reader.Namespace; var sub = xml.Descendant(ns + "div", new XAttribute("class", "main-subcontent-page")); // タイトル info.Title = sub.Descendant(ns + "li", new XAttribute("class", "title")).Value; // キャスト var casts = sub.Descendant(ns + "span", "主演女優: ").Parent; info.Casts = casts.Descendants(ns + "a").Select(a => a.Value).ToArray(); // シリーズ info.Series = (sub.ToString().Contains("シリーズ:")) ? sub.Descendant(ns + "span", "シリーズ:").Parent.Element(ns + "a").Value : string.Empty; // メーカー var makers = sub.Descendant(ns + "span", "スタジオ:").Parent; info.Makers = makers.Descendants(ns + "a").Select(a => a.Value).ToArray(); // レーベル info.Labels = new string[0]; // ジャンル var genres = sub.Descendant(ns + "span", "カテゴリ一覧:").Parent; info.Genres = genres.Descendants(ns + "a").Select(a => a.Value).ToArray(); // コメント var comment = sub.Descendant(ns + "div", new XAttribute("class", "title2")).NextElement(); info.Comment = comment.Value; // CenAvId info.CenAvId = xml.Descendant(ns + "div", new XAttribute("class", "top-title")).Value.Replace("商品番号:", "").Trim(); // Number info.Number = Convert.ToUInt32(Regex.Match(info.CenAvId, @"[0-9]+").Value); // イメージ var imageUrl = sub.Descendants(ns + "img").First().Attribute("src").Value.Replace("jacket_images", "bigcover"); using (WebClient client = new WebClient()) { using (MemoryStream stream = new MemoryStream(client.DownloadData(imageUrl))) { info.Pictures = new IPicture[]{ new Picture() { Type = PictureType.FrontCover, MimeType = "image/jpeg", Description = "Cover", Data = ByteVector.FromStream(stream) } }; } } info.Images = ((Func<BitmapSource[]>)(() => { ImageConverter ic = new ImageConverter(); return info.Pictures.Select( p => (ic.ConvertFrom(p.Data.Data) as Bitmap).ToWPFBitmap()).ToArray(); }))(); info.IsEmpty = false; return info; } catch (Exception ex) { throw new ApplicationException("アイテム要素が見つかりませんでした。", ex); } }
public override TagInfo GetItem(string searchWord) { try { TagInfo info = TagInfo.New(); HtmlReader reader = new HtmlReader(GetPageUrl(searchWord), encoding: enc); XDocument xml = reader.Html; XNamespace ns = reader.Namespace; var content = xml.Descendant(ns + "div", new XAttribute("class", "main-content-movieinfo")); var id = new Regex("[0-9]{6}_[0-9]{3}").Match(reader.Uri).Value; // タイトル info.Title = content.Descendant(ns + "div", new XAttribute("class", "video-detail")).Value.Trim(); // キャスト XElement cast = content.Descendants(ns + "dt").Where(a => a.Value == "出演:").FirstOrDefault(); info.Casts = (cast != null) ? cast.Descendants(ns + "a").Select(a => a.Value).ToArray() : new string[0]; // シリーズ XElement series = content.Descendants(ns + "dt").Where(a => a.Value == "シリーズ:").FirstOrDefault(); info.Series = (series != null) ? series.NextElement().Value.Trim() : string.Empty; // メーカー info.Makers = new string[] { "カリビアンコム プレミアム" }; // レーベル info.Labels = new string[0]; // ジャンル XElement genres = content.Descendant(ns + "dl", new XAttribute("class", "movie-info-cat")); info.Genres = (genres != null) ? genres.Descendants(ns + "a").Select(a => a.Value).ToArray() : new string[0]; // コメント XElement comment = content.Descendant(ns + "div", new XAttribute("class", "movie-comment")); info.Comment = (comment != null) ? comment.FirstNode.ToString() : string.Empty; // CenAvId info.CenAvId = "CaribbeanPr-" + id; // Number info.Number = Convert.ToUInt32(id.Replace("_", "")); // イメージ string imageUrl = @"http://www.caribbeancompr.com/moviepages/" + id + "/images/l_l.jpg"; using (WebClient client = new WebClient()) { using (MemoryStream stream = new MemoryStream(client.DownloadData(imageUrl))) { info.Pictures = new IPicture[]{ new Picture() { Type = PictureType.FrontCover, MimeType = "image/jpeg", Description = "Cover", Data = ByteVector.FromStream(stream) } }; } } info.Images = ((Func<BitmapSource[]>)(() => { ImageConverter ic = new ImageConverter(); return info.Pictures.Select( p => (ic.ConvertFrom(p.Data.Data) as Bitmap).ToWPFBitmap()).ToArray(); }))(); info.IsEmpty = false; return info; } catch (Exception ex) { throw new ApplicationException("アイテム要素が見つかりませんでした。", ex); } }
private string GetPageUrl(string searchWord) { if (Regex.IsMatch(searchWord, "[0-9]{6}_[0-9]{3}")) { return @"http://www.caribbeancompr.com/moviepages/" + searchWord + "/index.html"; } else { string url = @"http://www.caribbeancompr.com/search/?q=" + HttpUtility.UrlEncode(searchWord, enc); try { HtmlReader reader = new HtmlReader(url, encoding: enc); XDocument xml = reader.Html; XNamespace ns = reader.Namespace; var contents = xml.Descendant(ns + "div", new XAttribute("id", "main-content")); return @"http://www.caribbeancompr.com" + contents.Descendants(ns + "a").First().Attribute("href").Value; } catch (Exception ex) { throw new ApplicationException("ページが見つかりませんでした。", ex); } } }
public override TagInfo GetItem(string searchWord) { try { TagInfo info = TagInfo.New(); if (cache == null) cache = new HtmlReader("http://www.1pondo.tv/static-seo/sitemap-videos.xml"); HtmlReader reader = cache; XDocument xml = reader.Html; XNamespace ns = reader.Namespace; XNamespace video = reader.Html.Root.Attribute(XNamespace.Xmlns + "video").Value; XElement target = (Regex.IsMatch(searchWord, "[0-9]{6}_[0-9]{3}")) ? xml.Descendants(video + "content_loc").First(a => a.Value.Contains(searchWord)).Ancestors(video + "video").First() : xml.Descendants(video + "title").First(a => a.Value.Contains(searchWord)).Ancestors(video + "video").First(); var id = new Regex("[0-9]{6}_[0-9]{3}").Match(target.Element(video +"thumbnail_loc").Value).Value; string cast = target.Element(video + "tag").Value; // タイトル info.Title = target.Element(video + "title").Value.Split('|')[0].Substring(cast.Length).Trim(); // キャスト info.Casts = (cast != null) ? cast.Split(',') : new string[0]; // シリーズ info.Series = string.Empty; // メーカー info.Makers = new string[] { "一本道" }; // レーベル info.Labels = new string[0]; // ジャンル info.Genres = target.Descendants(video + "tag").Skip(1).Select(a => a.Value).ToArray(); // コメント info.Comment = target.Element(video + "description").Value; // CenAvId info.CenAvId = "1Pondo-" + id; // Number info.Number = Convert.ToUInt32(id.Replace("_", "")); // イメージ string imageUrl = target.Element(video + "thumbnail_loc").Value; using (WebClient client = new WebClient()) { using (MemoryStream stream = new MemoryStream(client.DownloadData(imageUrl))) { info.Pictures = new IPicture[]{ new Picture() { Type = PictureType.FrontCover, MimeType = "image/jpeg", Description = "Cover", Data = ByteVector.FromStream(stream) } }; } } info.Images = ((Func<BitmapSource[]>)(() => { ImageConverter ic = new ImageConverter(); return info.Pictures.Select( p => (ic.ConvertFrom(p.Data.Data) as Bitmap).ToWPFBitmap()).ToArray(); }))(); info.IsEmpty = false; return info; } catch (Exception ex) { throw new ApplicationException("アイテム要素が見つかりませんでした。", ex); } }
public override TagInfo GetItem(string searchWord) { try { TagInfo info = TagInfo.New(); string url = @"http://www.xxx-av.com/mov/view/" + searchWord + ".html"; HtmlReader reader = new HtmlReader(url, true, ua); XDocument xml = reader.Html; XNamespace ns = reader.Namespace; var movie = xml.Descendant(ns + "div", new XAttribute("id", "movie")); // タイトル info.Title = movie.Descendant(ns + "div", new XAttribute("class", "movie_tt")).Value.Trim(); // キャスト XElement cast = movie.Descendant(ns + "p", new XAttribute("class", "act")); info.Casts = (cast != null) ? cast.Descendants(ns + "a").Select(a => a.Value).ToArray() : new string[0]; // シリーズ XElement series = movie.Descendant(ns + "dl", new XAttribute("class", "series")); info.Series = (series != null) ? series.Descendants(ns + "a").Select(a => a.Value).FirstOrDefault() : string.Empty; // メーカー info.Makers = new string[] { "トリプルエックス" }; // レーベル info.Labels = new string[0]; // ジャンル XElement genres = movie.Descendant(ns + "dl", new XAttribute("class", "word")); info.Genres = (genres != null) ? genres.Descendants(ns + "a").Select(a => a.Value).ToArray() : new string[0]; var data = xml.Descendant(ns + "div", new XAttribute("class", "movie_data")); // コメント XElement comment = data.Descendant(ns + "dt", "コメント").NextElement(); info.Comment = (comment != null) ? comment.Value : string.Empty; // CenAvId info.CenAvId = "XXX-" + searchWord; // Number info.Number = Convert.ToUInt32(searchWord); // イメージ string imageUrl = "http://image.xxx-av.com/image/" + searchWord + "/movie_main.jpg"; using (WebClient client = new WebClient()) { using (MemoryStream stream = new MemoryStream(client.DownloadData(imageUrl))) { info.Pictures = new IPicture[]{ new Picture() { Type = PictureType.FrontCover, MimeType = "image/jpeg", Description = "Cover", Data = ByteVector.FromStream(stream) } }; } } info.Images = ((Func<BitmapSource[]>)(() => { ImageConverter ic = new ImageConverter(); return info.Pictures.Select( p => (ic.ConvertFrom(p.Data.Data) as Bitmap).ToWPFBitmap()).ToArray(); }))(); info.IsEmpty = false; return info; } catch (Exception ex) { throw new ApplicationException("アイテム要素が見つかりませんでした。", ex); } }