예제 #1
0
파일: AnimeInfo.cs 프로젝트: he305/sharpbot
        public async Task GetSynonyms()
        {
            var httpClient = new HttpClient();

            try
            {
                var htmlDoc = await NetUtills.GetHtmlDoc(BaseUrl + _id);

                if (htmlDoc == null)
                {
                    return;
                }

                var node = htmlDoc.DocumentNode.SelectSingleNode("//td[@class='borderClass']");
                var divs = node.Descendants(0).Where(n => n.HasClass("spaceit_pad"));

                foreach (var div in divs)
                {
                    _synonyms.Add(div.SelectSingleNode("text()[normalize-space()]").InnerText.Trim());
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                if (e.InnerException != null)
                {
                    Console.WriteLine(e.InnerException.Message);
                }
            }
        }
예제 #2
0
파일: AnimeInfo.cs 프로젝트: he305/sharpbot
        public async Task <List <string> > GetRecomendations()
        {
            var recs = new List <string>();

            try
            {
                var htmlDoc = await NetUtills.GetHtmlDoc(BaseUrl + _id);

                if (htmlDoc == null)
                {
                    return(recs);
                }

                var node = htmlDoc.DocumentNode.SelectSingleNode("//ul[@class='anime-slide js-anime-slide']");
                var lis  = node.Descendants(0).Where(n => n.HasClass("btn-anime"));

                foreach (var li in lis)
                {
                    recs.Add(li.Attributes["title"].Value);
                }
            }
            catch (Exception e)
            {
                System.Console.WriteLine($"Error getting recommendations: {e.Message}");
            }
            return(recs);
        }