コード例 #1
0
        public PremarketDataResponseDto CreateInstanceBasedOnHtmlContent(string html)
        {
            var dto = new PremarketDataResponseDto {
            };

            var htmlElement = _lookup.FindHtmlElementByClass(html, "element--intraday");

            dto.Symbol = _lookup.FindHtmlElementByClass(htmlElement, "company__ticker", true);
            dto.Market = _lookup.FindHtmlElementByClass(htmlElement, "company__market", true);

            var priceSectionElement = _lookup.FindHtmlElementByClass(htmlElement, "intraday__data");

            dto.Price                 = _lookup.FindHtmlElementByClass(priceSectionElement, "value", true);
            dto.PriceChange           = _lookup.FindHtmlElementByClass(priceSectionElement, "change--point--q", true);
            dto.PriceChangePercantage = _lookup.FindHtmlElementByClass(priceSectionElement, "change--percent--q", true);

            var previousCloseElement = _lookup.FindHtmlElementByClass(htmlElement, "intraday__close");

            dto.PreviuosClose = _lookup.FindHtmlElementByClass(previousCloseElement, "table__cell u-semi", true);

            var timeStampSectionElement = _lookup.FindHtmlElementByClass(htmlElement, "timestamp__time");

            dto.LastUpdate = _lookup.FindHtmlElementByTag(timeStampSectionElement, "bg-quote", true);

            return(dto);
        }
コード例 #2
0
        /// <summary>
        /// Fill instance with stock symbol, stock name, country origin etc.
        /// </summary>
        /// <param name="html"></param>
        /// <param name="dto"></param>
        private void FillBasicStockInfo(string html, StockInfoClientResponseDto dto)
        {
            _logger.LogInformation("Filling basic info about given ticker");

            dto.Symbol = _lookup.FindHtmlElementById(html, "ticker", true);

            var htmlSection = _lookup.FindHtmlElementByClass(html, "fullview-title");

            var fullNameHtmlSection = _lookup.FindHtmlElementByTag(htmlSection, "tr", 1); // --> fullname table row

            dto.Name = _lookup.FindHtmlElementByTag(fullNameHtmlSection, "b", true);

            var sectorDetailsHtmlSection = _lookup.FindHtmlElementByTag(htmlSection, "tr", 2); // --> sector table row

            dto.Sector    = _lookup.FindHtmlElementByTag(sectorDetailsHtmlSection, "a", 0, true);
            dto.SubSector = _lookup.FindHtmlElementByTag(sectorDetailsHtmlSection, "a", 1, true);
            dto.Country   = _lookup.FindHtmlElementByTag(sectorDetailsHtmlSection, "a", 2, true);

            dto.Description = _lookup.FindHtmlElementByClass(html, "fullview-profile", true);

            _logger.LogInformation("Instance filled with basic info");
        }