Example #1
0
        /// <summary>
        /// 获得英雄的定位和背景
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public async static Task <HeroBio> GetHeroBio(string id, string html)
        {
            if (html == null)
            {
                await InitializeHtml(id);
            }
            HeroBio heroBio = new HeroBio();

            try
            {
                MatchCollection matchCollection = Regex.Matches(html, "<span\\sclass=\\\"_btn_type\\\"\\sstar=\\\"\\d\\\"\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t \\stype=\\\"(.*?)\\\">");
                Match           matchAtk        = Regex.Match(html, "攻击类型:</span>\\n\\n\\t\\t\\t\\t\\t\\t\\t\\t<p\\sclass=\\\"info_p\\\"><span>(.*?)</span>");
                Match           matchBio        = Regex.Match(html, "</a>\\n\\t\\t\\t\\t\\t\\t</div>\\n\\t\\t\\t\\t\\t\\t([\\s\\S]*?)\\t\\t\\t\\t\\t</div>\\n\\t\\t\\t\\t\\t<div class=\\\"silide_r\\\">");
                heroBio.Atk = matchAtk.Groups[1].Value;
                heroBio.Bio = matchBio.Groups[1].Value.Replace("<br>", "");
                string role = "";
                foreach (Match item in matchCollection)
                {
                    role += "-";
                    role += item.Groups[1].Value;
                }
                heroBio.Role = role;
            }
            catch
            {
                return(null);
            }
            return(heroBio);
        }
Example #2
0
        /// <summary>
        /// 显示英雄定位和背景
        /// </summary>
        private async void ShowTheHeroBio(string html)
        {
            HeroBio heroBio = await CrawlerHelper.GetHeroBio(SelectedHero.ID, html);

            if (heroBio == null)
            {
                return;
            }
            AtkTextBlock.Text  = heroBio.Atk;
            RoleTextBlock.Text = heroBio.Role;
            if (heroBio.Bio.Replace(" ", "") == "")
            {
                heroBio.Bio = await CrawlerHelper.GetHeroBioBackup(SelectedHero.ID, html);
            }
            HeroInfoTextBlock.Text = heroBio.Bio;

            HeroBioProgressRing.IsActive   = false;
            HeroBioProgressRing.Visibility = Visibility.Collapsed;
        }