Exemplo n.º 1
0
        private void SetTeamNames(MatchInfo match)
        {
            IEnumerable<HtmlNode> tempNames = GetByClass("a", "nolinkstyle");

            match.FirstTeam = tempNames.First().InnerText.Replace("amp;", "");
            match.SecondTeam = tempNames.ElementAt(1).InnerText.Replace("amp;", "");

            //TODO: Выдирать линки на команды из странцы матча.
            //TODO: Исключать повторения, включая те линки, которые получены из таблицы.

            if (!TeamLinks.ContainsKey(match.FirstTeam))
            {
                if (tempNames.First().Attributes.Contains("href"))
                {
                    TeamLinks.Add(match.FirstTeam,
                        HltvUrl + "/" + tempNames.First().Attributes["href"].Value.Replace("amp;", ""));
                }
            }

            if (!TeamLinks.ContainsKey(match.SecondTeam))
            {
                if (tempNames.ElementAt(1).Attributes.Contains("href"))
                {
                    TeamLinks.Add(match.SecondTeam,
                        HltvUrl + "/" + tempNames.ElementAt(1).Attributes["href"].Value.Replace("amp;", ""));
                }
            }
        }
Exemplo n.º 2
0
 private void SetTeamNamesLegacy(MatchInfo match)
 {
 }
Exemplo n.º 3
0
        private void SetMapAndScore(MatchInfo match)
        {
            IEnumerable<HtmlNode> temp = GetByClass("div", "hotmatchbox")
                .Where(n => n.Attributes.Contains("style")
                    && n.Attributes["style"].Value.Contains("margin-top: -7px;font-size: 12px;width:270px;border-top:0;"));

            List<Score> tempScore = new List<Score>();
            foreach (HtmlNode node in temp)
            {
                tempScore.Add(new Score(Convert.ToInt32(node.ChildNodes[1].InnerText),
                    Convert.ToInt32(node.ChildNodes[3].InnerText)));
            }

            IEnumerable<HtmlNode> maps = Doc.DocumentNode.Descendants("img").Where(n =>
                n.Attributes.Contains("src") && n.Attributes["src"].Value.Contains("images/hotmatch")
                && n.Attributes.Contains("style") && !n.Attributes["style"].Value.Contains("opacity:0.4"));

            int i = 0;
            foreach (HtmlNode node in maps)
            {
                try
                {
                    string map = Regex.Match(
                        Regex.Match(node.Attributes["src"].Value, "[a-zA-Z0-9_-]*[.]png|jpg|bmp|tiff|tga|gif")
                        .Value, "[a-zA-Z0-9-_]{4,}").Value;
                    if (map == "")
                    {
                        map = "tba";
                    }

                    match.Maps.Add(map, tempScore[i]);
                }
                catch
                {
                    try
                    {
                        match.Maps.Add("Unknown", tempScore[i]);
                    }
                    catch
                    {
                        continue;
                    }
                }
                i++;
            }
        }
Exemplo n.º 4
0
 private void SetMapAndScoreLegacy(MatchInfo match)
 {
 }
Exemplo n.º 5
0
 private void SetDateLegacy(MatchInfo match)
 {
     string date = Doc.DocumentNode.Descendants("td").Where(n =>
         n.InnerText == "Time:").First().NextSibling.InnerText;
 }
Exemplo n.º 6
0
 private void SetDate(MatchInfo match)
 {
     try
     {
         match.Date = HltvDateParser.Parse(Doc.DocumentNode.Descendants("span").Where(n => n.Attributes.Contains("style")
             && n.Attributes["style"].Value.Contains("font-size:14px;")).First().ParentNode.InnerText);
     }
     catch
     {
         try
         {
             match.Date = HltvDateParser.Parse(Doc.DocumentNode.Descendants("div").Where(n =>
                 n.Attributes.Contains("style") && n.Attributes["style"].Value.Contains("text-align:center;font-size: 18px;"))
                 .First().InnerText);
         }
         catch
         {
             match.Date = new DateTime(1990, 1, 1, 0, 0, 0);
         }
     }
 }
Exemplo n.º 7
0
        //http://www.hltv.org/legacy/match/2292334-global-vexx-cevo-professional-season-5
        private void ParseDetailsLegacy(string url)
        {
            Doc.LoadHtml(GetStringFromUrl(url));

            MatchInfo match = new MatchInfo();
            match.Url = url;
            SetDateLegacy(match);
            SetMapAndScoreLegacy(match);
            SetTeamNamesLegacy(match);

            Matches.Add(match);

            PrintOutput(match.Print(), 1);
        }
Exemplo n.º 8
0
        private void ParseDetails()
        {
            foreach (string url in DetailsUrls)
            {
                if (url == "http://www.hltv.org/match/")
                {
                    continue;
                }

                if (url == "http://www.hltv.org/match/2292334-global-vexx-cevo-professional-season-5")
                {
                    //ParseDetailsLegacy(url);
                    break;
                }
                Doc.LoadHtml(GetStringFromUrl(url));

                MatchInfo match = new MatchInfo();
                match.Url = url;
                SetDate(match);
                SetMapAndScore(match);
                SetTeamNames(match);

                Matches.Add(match);

                PrintOutput(match.Print(), 1);
            }
        }
Exemplo n.º 9
0
        public static MatchInfo ParseMatch(string url)
        {
            HtmlDocument doc = new HtmlDocument();
            doc.LoadHtml(new WebClient().DownloadString(url));

            MatchInfo match = new MatchInfo();
            match.Url = url;

            IEnumerable<HtmlNode> tempNames = doc.DocumentNode.Descendants("a").
                Where(n => n.Attributes.Contains("class")
                    && n.Attributes["class"].Value.Contains("nolinkstyle"));

            match.FirstTeam = tempNames.First().InnerText.Replace("amp;", "");
            match.SecondTeam = tempNames.ElementAt(1).InnerText.Replace("amp;", "");

            return match;
        }