public Movie GetMovie(MovieBasic movieBasic) { //wc.Headers.Set("Referer", "http://www.aventertainments.com/search_Products.aspx?languageID=2&searchby=keyword&keyword=cwp"); //wc.Headers.Set("Host", "www.aventertainments.com"); //wc.Headers.Set("Content-Type", "application/x-www-form-urlencoded"); wc.Headers.Set("User-Agent", "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1985.143 Safari/537.36"); string html = wc.GetHTML(new Uri(movieBasic.ItemURL)); var docc = new HtmlDocument(); docc.LoadHtml(html); string Title = movieBasic.Title; string label = docc.DocumentNode.SelectNodes("//span[@class='redtitle']")[3].ParentNode.InnerText; string changjia = docc.DocumentNode.SelectNodes("//span[@class='redtitle']")[1].ParentNode.ChildNodes["a"].InnerText; string jiandu = string.Empty; string date = docc.DocumentNode.SelectNodes("//span[@class='redtitle']")[4].ParentNode.InnerText; string minutes = docc.DocumentNode.SelectNodes("//span[@class='redtitle']")[5].ParentNode.InnerText; string f_code = docc.DocumentNode.SelectNodes("//div[@class='top-title']")[0].InnerText.Replace("商品番号:", ""); string xilie = docc.DocumentNode.SelectNodes("//span[@class='redtitle']")[2].ParentNode.ChildNodes["a"].InnerText; string intro = docc.DocumentNode.SelectNodes("//div[@id='titlebox']/div[5]/p")[0].InnerText; string coverImage = docc.DocumentNode.SelectNodes("//div[@class='top_sample']")[0].InnerText.Trim(); var imageFlag = "image: '"; //找到imageFlag var st_num = coverImage.IndexOf(imageFlag); //找到imageFlag之后的引号 var ed_num = coverImage.IndexOf('\'', st_num + imageFlag.Length); //截取刚才的两个找到的中间部分 coverImage = coverImage.Substring(st_num + imageFlag.Length, ed_num - st_num - imageFlag.Length); System.Text.RegularExpressions.Regex r = new System.Text.RegularExpressions.Regex(@"\d{1,2}/\d{1,2}/\d{4}"); date = r.Match(date).Value; //*[@id="titlebox"]/ul[3]/li[5] Movie m = new Movie() { Title = Title, Lable = label, Maker = changjia, ReleaseDate = DateTime.Parse(date), Minutes = minutes, AVCode = f_code, Introduction = intro, Actor = movieBasic.Actor, ItemURL = movieBasic.ItemURL, CoverURL = coverImage, Producer = jiandu, Series = xilie }; return(m); }
public List <MovieBasic> Query(string keyword) { Uri u = urlCombine(keyword); HtmlDocument doc = new HtmlDocument(); wc.Headers.Set("User-Agent", "Mozilla/5.0 (Windows; U; Windows NT 5.2; zh-TW; rv:1.9.1.5) Gecko/20091102 Firefox/3.5.5"); wc.Headers.Set("Referer", "http://aventertainments.com/Main.aspx?languageID=2"); wc.Headers.Set("Content-Type", "application/x-www-form-urlencoded"); string htmlString = wc.GetHTML(u); doc.LoadHtml(htmlString); var listItems = doc.DocumentNode.SelectNodes("//table[@id='ctl00_ContentPlaceHolder1_Rows2Items1_MyList']/tr/td[@valign='top']/table"); List <MovieBasic> l = new List <MovieBasic>(); if (listItems == null) { return(l); } foreach (var item in listItems) { var title = item.ChildNodes["tr"].ChildNodes["td"].ChildNodes["h4"].InnerText; //listItems[0].ChildNodes["table"].ChildNodes["tr"].ChildNodes["td"].ChildNodes["h4"].InnerText; title = title.Trim(" ".ToArray()); var img_s = item.ChildNodes["tr"].ChildNodes["td"].ChildNodes["div"].ChildNodes["a"].ChildNodes["img"].Attributes["src"].Value; var actor = item.ChildNodes["tr"].ChildNodes["td"].ChildNodes["a"].InnerText; var maker = item.ChildNodes["tr"].ChildNodes["td"].Elements("a").ElementAt(1).InnerText; var itemURL = item.ChildNodes["tr"].ChildNodes["td"].ChildNodes["h4"].ChildNodes["a"].Attributes["href"].Value; var label = item.ChildNodes["tr"].ChildNodes["td"].InnerText; int st = label.IndexOf("商品番号:") + 5; int ed = label.IndexOf("発売日"); label = label.Substring(st, ed - st).Trim().Trim(" ".ToArray()); var _actorList = new List <string>(); _actorList.Add(actor); MovieBasic mb = new MovieBasic() { Title = title, Img_s = img_s, Actor = _actorList, ItemURL = itemURL, Label = label, Maker = maker }; l.Add(mb); } return(l); //wc.Headers.Add("Content-Type", "application/x-www-form-urlencoded"); //wc.Headers.Add(System.Net.HttpRequestHeader.Referer, "https://www.aventertainments.com/login.aspx?languageID=1"); //NameValueCollection nvc = new NameValueCollection(); //nvc.Add("ctl00$ContentPlaceHolder1$uid","*****@*****.**"); //nvc.Add("ctl00$ContentPlaceHolder1$passwd", "177991"); //wc.UploadData("https://www.aventertainments.com/login.aspx?languageID=1", "POST", nvc); }
private List <MovieBasic> PageParse(Uri u) { HtmlAgilityPack.HtmlDocument doc = new HtmlDocument(); doc.LoadHtml(wc.GetHTML(u)); //doc.DocumentNode.SelectNodes("//li[@class='saledate']/span")[3].InnerText var listitems = doc.DocumentNode.SelectNodes("//div[@id='listitem']/table/tr/td/div[@class='data']/ul[1]/li[2]"); var htmnode = doc.DocumentNode.SelectSingleNode("//div[@class='autopagerize_page_element']"); if (htmnode == null) { //查无此片 return(new List <MovieBasic>()); } string htm = htmnode.InnerHtml; List <MovieBasic> l = new List <MovieBasic>(); //<div class="autopagerize_page_element"> int cou = doc.DocumentNode.SelectNodes("//div[@id='itemd']").Count; for (int i = 0; i < cou; i++) { string n_title = doc.DocumentNode.SelectNodes("//div[@id='itemd']//h2/a")[i].InnerText; n_title = Tools.RemoveInvalidChars(n_title); string n_itemURL = "http://" + u.Host + doc.DocumentNode.SelectNodes("//div[@id='itemd']//h2/a")[i].Attributes["href"].Value; string n_date = doc.DocumentNode.SelectNodes("//div[@id='itemd']//span")[i].InnerText.Trim(); var datanode = doc.DocumentNode.SelectNodes("//div[@class='data']")[i]; HtmlDocument docData = new HtmlDocument(); docData.LoadHtml(datanode.InnerHtml); int k = docData.DocumentNode.SelectNodes("//ul[1]/li").Count; string n_actor = string.Empty; List <string> actors = new List <string>(); if (k > 1) { for (int j = k; j > 1; j--) { n_actor = docData.DocumentNode.SelectNodes("//ul[1]/li[" + j + "]")[0].InnerText.Trim(); actors.Add(n_actor); } } string n_maker = docData.DocumentNode.SelectSingleNode("//ul[2]/li[2]").InnerText.Trim(); string n_company = docData.DocumentNode.SelectSingleNode("//ul[3]/li[2]").InnerText.Trim(); var n_ticai_node = docData.DocumentNode.SelectSingleNode("//ul[4]/li[2]"); string n_ticai; if (n_ticai_node == null) { n_ticai = string.Empty; } else { n_ticai = n_ticai_node.InnerText.Trim(); } string s_img = doc.DocumentNode.SelectNodes("//div[@id='listitem']/table/tr/td/div/a/img")[i].Attributes["src"].Value; MovieBasic mb = new MovieBasic() { Title = n_title, ItemURL = n_itemURL, Img_s = s_img, Actor = actors, Maker = n_company, Label = n_ticai }; l.Add(mb); } return(l); }
Movie mb_2_m(MovieBasic mb) { var new_a = this.arzon.Clone() as Arzon; return(new_a.GetMovie(mb)); }
/// <summary> /// this is the old version. /// </summary> /// <param name="basic"></param> /// <returns></returns> //public Movie GetMovie(MovieBasic basic) //{ // try // { // string html = wc.GetHTML(new Uri(basic.ItemURL)); // var docc = new HtmlDocument(); // docc.LoadHtml(html); // //web DOM Changed 2014/12/7 // string Title = docc.DocumentNode.SelectSingleNode("//div[@id='detail_new']/div[@class='detail_title']/h1").InnerText.Trim(); // //string Title = docc.DocumentNode.SelectSingleNode("//div[@id='detail_new']/div[@class='detail_title_new']/h1").InnerHtml; // Title = Tools.RemoveInvalidChars(Title); // while (Title.IndexOf(" ") != -1) // { // Title= Title.Replace(" ", ""); // } // while (Title.IndexOf("廃盤") != -1) // { // Title = Title.Replace("廃盤", ""); // } // //var ddd ="[MIDD-983]Baby Entertainment×MOODYZコラボ作品 淫神の女泥棒 哀しき痙攣の追憶 Dear.F 1 恥辱的、屈辱的なイカせの拷問! 反反复复反反复复方法"; // if (Title.Length>82) // { // Title = Title.Substring(0, 81); // } // //string Title = basic.Title; // string label = docc.DocumentNode.SelectSingleNode("//div[@id='detail_new']/table/tr/td/table[@class='item_detail']/tr/td[@class='caption']/table[@class='item']/tr[3]/td/a").InnerText.Trim(); // string changjia = docc.DocumentNode.SelectSingleNode("//div[@id='detail_new']/table/tr/td/table[@class='item_detail']/tr/td[@class='caption']/table[@class='item']/tr[2]/td/a").InnerText.Trim(); // string jiandu = docc.DocumentNode.SelectSingleNode("//div[@id='detail_new']/table/tr/td/table[@class='item_detail']/tr/td[@class='caption']/table[@class='item']/tr[5]/td[2]").InnerText.Trim(); // string date = docc.DocumentNode.SelectSingleNode("//div[@id='detail_new']/table/tr/td/table[@class='item_detail']/tr/td[@class='caption']/table[@class='item']/tr[6]/td[2]").InnerText.Trim(); // //2008/01/25 (DVD レンタル版) // System.Text.RegularExpressions.Regex r = new System.Text.RegularExpressions.Regex(@"\d{4}/\d{2}/\d{2}"); // if (r.IsMatch(date)) // { // date = r.Match(date).Value; // } // else // { // date = "1900/01/01"; // } // DateTime dtime = DateTime.Parse(date); // string minutes = docc.DocumentNode.SelectSingleNode("//div[@id='detail_new']/table/tr/td/table[@class='item_detail']/tr/td[@class='caption']/table[@class='item']/tr[7]/td[2]").InnerText.Trim(); // string f_code = docc.DocumentNode.SelectSingleNode("//div[@id='detail_new']/table/tr/td/table[@class='item_detail']/tr/td[@class='caption']/table[@class='item']/tr[8]/td[2]").InnerText.Trim(); // while (f_code.IndexOf(" ")!=-1) // { // f_code = f_code.Replace(" ", ""); // } // while (f_code.IndexOf("廃盤")!=-1) // { // f_code = f_code.Replace("廃盤", ""); // } // f_code = Tools.Fcode(f_code); // string xilie = docc.DocumentNode.SelectSingleNode("//div[@id='detail_new']/table/tr/td/table[@class='item_detail']/tr/td[@class='caption']/table[@class='item']/tr[4]/td[2]").InnerText.Trim(); // //f_code = Tools.Fcode(f_code); // string intro = docc.DocumentNode.SelectSingleNode("//table[@class='item_detail']/tr/td[@class='text']").InnerText.Trim(); // string coverImg = docc.DocumentNode.SelectSingleNode("//table[@class='item_detail']/tr/td/div/a").Attributes["href"].Value.Trim(); // Movie m = new Movie() // { // Actor = basic.Actor, // Title = Title, // Lable = label, // Maker = changjia, // ReleaseDate = dtime, // Minutes = minutes, // AVCode = f_code, // Introduction = intro, // CoverURL = coverImg, // ItemURL = basic.ItemURL, // Series = xilie, // Producer = jiandu // }; // //Console.WriteLine(string.Format("Actor:{0}\r\nTitle:{1}\r\nLabel:{2}\r\nMaker:{3}\r\nReleaseDate:{4}\r\n番号:{5}\r\n ", m.Actor[0], m.Title, m.Lable, m.Maker, m.ReleaseDate.ToShortDateString(), m.AVCode)); // return m; // } // catch (Exception) // { // throw new Exception("获取影片信息失败!"); // } //} public Movie GetMovie(MovieBasic basic) { try { string html = wc.GetHTML(new Uri(basic.ItemURL)); var docc = new HtmlDocument(); docc.LoadHtml(html); //web DOM Changed 2014/12/7 string Title = docc.DocumentNode.SelectSingleNode("//div[@id='detail_new']//div[@class='detail_title_new2']//h1").InnerText; string coverImg = docc.DocumentNode.SelectNodes("//div[@id='detail_new']//img[@class='item_img']")[0].Attributes["src"].Value.ToString(); if (coverImg.StartsWith("//")) { coverImg = "http:" + coverImg; } //AV女優: var item1 = docc.DocumentNode.SelectSingleNode("//table[@class='item']/tr[1]/td[2]").InnerText.Trim(); var actorsArr = item1.Split(new char[] { '\r', ' ', '\n' }, StringSplitOptions.RemoveEmptyEntries).ToList <string>(); //AVメーカー 制造厂 var item2 = docc.DocumentNode.SelectSingleNode("//table[@class='item']/tr[2]/td[2]").InnerText.Trim(); //AVレーベル 唱片公司 var item3 = docc.DocumentNode.SelectSingleNode("//table[@class='item']/tr[3]/td[2]").InnerText.Trim(); //シリーズ 系列 var item4 = docc.DocumentNode.SelectSingleNode("//table[@class='item']/tr[4]/td[2]").InnerText.Trim(); //監督 导演 var item5 = docc.DocumentNode.SelectSingleNode("//table[@class='item']/tr[5]/td[2]").InnerText.Trim(); //発売日: var item6 = docc.DocumentNode.SelectSingleNode("//table[@class='item']/tr[6]/td[2]").InnerText.Trim(); //収録時間 var item7 = docc.DocumentNode.SelectSingleNode("//table[@class='item']/tr[7]/td[2]").InnerText.Trim(); //品番 var item8 = docc.DocumentNode.SelectSingleNode("//table[@class='item']/tr[8]/td[2]").InnerText.Trim(); //タグ: 标签 var item9 = docc.DocumentNode.SelectSingleNode("//table[@class='item']/tr[9]/td[2]").InnerText.Trim(); //作品紹介 string descrition; try { descrition = docc.DocumentNode.SelectSingleNode("//div[@class='item_text']").InnerText.Trim(); } catch (Exception) { descrition = ""; } Movie m = new Movie() { Actor = actorsArr, Title = titleCleaner(Title), Lable = item9, Maker = item2,//ideapocket ReleaseDate = dateCleaner(item6), Minutes = item7, AVCode = f_codeCleaner(item8), Introduction = descrition, CoverURL = coverImg, ItemURL = basic.ItemURL, Series = item4, //导演 Producer = item5 }; //Console.WriteLine(string.Format("Actor:{0}\r\nTitle:{1}\r\nLabel:{2}\r\nMaker:{3}\r\nReleaseDate:{4}\r\n番号:{5}\r\n ", m.Actor[0], m.Title, m.Lable, m.Maker, m.ReleaseDate.ToShortDateString(), m.AVCode)); return(m); } catch (Exception) { throw new Exception("获取影片信息失败!"); } }