Пример #1
0
        public WorldCasesInfo GetCasesInfo(string url, string countryName)
        {
            var htmlnode = webScrapper.GetHtml(url);

            _caseInfo = webScrapper.GetCasesInfo(htmlnode, _caseInfo);

            if (_caseInfo.GetType() == typeof(CountryCaseInfo))
            {
                ((CountryCaseInfo)_caseInfo).CountryName = countryName;
            }

            return(_caseInfo);
        }
        public WorldCasesInfo GetCasesInfo(HtmlNode htmlNode, WorldCasesInfo casesInfo)
        {
            var selectNodes = htmlNode.OwnerDocument.DocumentNode.SelectNodes("//div[@id='maincounter-wrap']");

            foreach (var node in selectNodes)
            {
                string header = node.ChildNodes["h1"].InnerText;
                if (header.Equals("Coronavirus Cases:"))
                {
                    casesInfo.TotalCases = Convert.ToDouble(node.ChildNodes["div"].InnerText);
                }
                else if (header.Equals("Deaths:"))
                {
                    casesInfo.Deaths = Convert.ToDouble(node.ChildNodes["div"].InnerText);
                }
                else
                {
                    casesInfo.Recovered = Convert.ToDouble(node.ChildNodes["div"].InnerText);
                }
            }

            return(casesInfo);
        }
Пример #3
0
 public CaseProcessor(WorldCasesInfo casesInfo)
 {
     this._caseInfo   = casesInfo;
     this.webScrapper = new WebScarpper();
 }