Esempio n. 1
0
        private static CoronaData GetFromTable(HtmlDocument coronaStats, string time)
        {
            var result    = new CoronaData();
            var countries = coronaStats.DocumentNode
                            .SelectNodes($"//*[@id=\"main_table_countries_{time}\"]/tbody[1]/tr")
                            .Where(t => !t.GetAttributeValue("class", "").Contains("total_row_world"));

            foreach (var country in countries)
            {
                var entry = new CoronaData.CoronaEntry();
                var cells = country.SelectNodes("td");
                entry.Name = cells[1].InnerText.Trim();
                entry.Type = cells[1].SelectSingleNode("span") == null
                    ? CoronaData.CoronaEntryType.Country
                    : CoronaData.CoronaEntryType.Other;
                entry.Cases        = (int)ParseDouble(cells[2]);
                entry.CaseIncrease = (int)ParseDouble(cells[3]);
                entry.Deaths       = (int)ParseDouble(cells[4]);
                entry.Recovered    = (int)ParseDouble(cells[6]);
                entry.Serious      = (int)ParseDouble(cells[9]);

                result.Entries.Add(entry.Name, entry);
            }

            return(result);
        }
Esempio n. 2
0
        public static string GetCountryEmoji(CoronaData.CoronaEntry region)
        {
            var cc = "";

            if (region.Name == "UK")
            {
                cc = "GB";
            }

            if (region.Name == "S. Korea")
            {
                cc = "KR";
            }

            if (region.Name == "Diamond Princess")
            {
                return(":cruise_ship:");
            }

            if (cc == "")
            {
                cc = Countries.GetTwoLettersName(region.Name, false);
            }

            if (cc == "")
            {
                cc = new string(region.Name.Where(c => Char.IsLetter(c)).Take(2).ToArray());
            }

            return($":flag_{cc.ToLowerInvariant()}:");
        }