static public bool MakeMovieDB(HtmlElement movieElement, out MovieDB db) { db = new MovieDB(); foreach (HtmlElement item in movieElement.GetElementsByTagName("dt")) { foreach (HtmlElement item2 in item.GetElementsByTagName("a")) { db.title = item2.InnerText; db.url = item2.GetAttribute("href"); } } return(db.Is()); }
private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e) { if (webStatus == WebBrowserStatus.INFO) { db = WebLib.MakeMovieDB(webBrowser1.Document); MovePage(); } else if (webStatus == WebBrowserStatus.MOVIE_FIND) { WebLib.UpdateMovieDB(webBrowser1.Document, db); PrintReview(); Poster(); webStatus = WebBrowserStatus.END; } Output(db); }
private void Output(MovieDB db) { StringBuilder str = new StringBuilder(); str.AppendLine("URL : " + db.url); str.AppendLine("제목 : " + db.title); str.AppendLine("개봉일 : " + printList(db.releaseDate)); str.AppendLine("관람객 평점 : " + db.audRating); str.AppendLine("전문가 평점 : " + db.expRating); str.AppendLine("네티즌 평점 : " + db.netRating); str.AppendLine("장르 : " + printList(db.genre)); str.AppendLine("국가 : " + printList(db.nation)); str.AppendLine("감독 : " + printList(db.director)); str.AppendLine("배우 : " + printList(db.actor)); str.AppendLine("유사한 영화들 : " + printList(db.recommendMovies)); txtBox.Text = str.ToString(); }
public static void GetRecommendMovies(HtmlElement movie, MovieDB db) { HtmlElement listMovies = GetElementsByTagAndClassName(movie, "div", "link_movie type2")[0]; int linelindex = 0; foreach (HtmlElement item in listMovies.GetElementsByTagName("ul")) { if (linelindex == 0) { string text = item.InnerText; text = text.Replace("\r\n", ","); text = text.Replace(",,, ,", string.Empty); text = text.Substring(4); string[] movies = text.Split(','); db.recommendMovies.AddRange(movies); } } }
static public void GetRatings(HtmlElement movie, MovieDB db) { List <HtmlElement> listRatings = GetElementsByTagAndClassName(movie, "div", "star_score"); int lineIndex = 0; foreach (HtmlElement item in listRatings) { if (lineIndex == 0) { db.audRating = CountRatings(item); } else if (lineIndex == 1) { db.expRating = CountRatings(item); } lineIndex++; } HtmlElement netRatings = GetElementsByTagAndClassName(movie, "div", "star_score ")[0]; db.netRating = CountRatings(netRatings); }