public List <AnimeResult> SearchAnime(string query) { var html = _client.DownloadString(BaseUri + string.Format(SearchString, query)); var dom = CQ.CreateDocument(html); var results = new List <AnimeResult>(); if (!string.IsNullOrEmpty(dom.Select(".pagination-list li").Text())) { var totalPages = Convert.ToInt32(dom.Select(".pagination-list li").Last().Text()); for (var page = 1; page <= totalPages; page++) { var pageHtml = _client.DownloadString(BaseUri + string.Format(SearchPageString, query, page)); var pageDom = CQ.CreateDocument(pageHtml); results.AddRange(pageDom.Select(".items li") .Select(element => new AnimeResult { Name = element.Cq().Find(".name").Text(), CoverUrl = element.Cq().Find("img").Attr("src"), PageUrl = BaseUri + element.Cq().Find("a").Attr("href"), KitsuSearchResult = _kitsu.SearchAnime(element.Cq().Find(".name").Text()).Data?.First() }) .ToList()); } } else { results = dom.Select(".items li") .Select(element => new AnimeResult { Name = element.Cq().Find(".name").Text(), CoverUrl = element.Cq().Find("img").Attr("src"), PageUrl = BaseUri + element.Cq().Find("a").Attr("href"), KitsuSearchResult = _kitsu.SearchAnime(element.Cq().Find(".name").Text()).Data?.First() }) .ToList(); } return(results); }
public List <AnimeResult> SearchAnime(string query) { var html = _cloudHttpClient.GetStringAsync(BaseUri + string.Format(SearchString, query)).Result; var dom = CQ.CreateDocument(html); var results = dom.Select(".animelist_poster") .Select(element => new AnimeResult { Name = element.Cq().Find("center").Text(), CoverUrl = BaseUri + element.Cq().Select(".animelist_poster_caption").Prev().Attr("data-original"), PageUrl = element.Cq().Find("a").Attr("href"), KitsuSearchResult = _kitsu.SearchAnime(element.Cq().Find("center").Text()).Data?.First() }) .ToList(); return(results); }
public List <AnimeResult> SearchAnime(string query) { var html = _client.DownloadString(BaseUri); var dom = CQ.CreateDocument(html); foreach (var result in dom.Select(".series-title")) { var alt = result.Cq().Attr("data-alt") ?? ""; _animeList.Add(result.Cq().Attr("data-title"), alt); } var results = (from item in _animeList where item.Key.ToLower().Contains(query.ToLower()) || item.Value.ToLower().Contains(query.ToLower()) select new AnimeResult { Name = item.Key, PageUrl = dom.Select($"[data-title='{item.Key}']").Attr("href"), KitsuSearchResult = _kitsu.SearchAnime(item.Key).Data?.First() }).ToList(); return(results); }
public List <AnimeResult> SearchAnime(string query) { var content = new FormUrlEncodedContent(new[] { new KeyValuePair <string, string>("anime_name", query) }); //var html = _httpClient.GetStringAsync(BaseUri + string.Format(SearchString, query)).Result; var html = _httpClient.PostAsync(BaseUri + SearchString, content).Result.ToString(); var dom = CQ.CreateDocument(html); var results = dom.Select(".ws-anime li") .Select(element => new AnimeResult { Name = element.Cq().Find("a").Eq(0).Text(), CoverUrl = BaseUri + element.Cq().Find("img").Attr("src"), PageUrl = element.Cq().Find("a").Eq(0).Attr("href"), KitsuSearchResult = _kitsu.SearchAnime(element.Cq().Find("a").Eq(0).Text()).Data?.First() }) .ToList(); return(results); }