public async Task CheckChange(Guid pageId)
        {
            var pageDto = await _pageService.GetPage(pageId);

            try
            {
                string webBody = await _websiteService.GetHtml(pageDto.Url);

                var primaryText = await _websiteTextService.GetText(pageDto.PrimaryTextId);

                if (pageDto.CheckingType == CheckingTypeEnum.Element)
                {
                    var webElement = HtmlHelper.GetNode(webBody, pageDto.ElementXPath);

                    if (HtmlHelper.Compare(primaryText.Text, webElement, CheckingTypeEnum.Full) == false)
                    {
                        await PageChanged(pageDto, primaryText.Text, webElement);
                    }
                }

                //if page changed now
                if (HtmlHelper.Compare(primaryText.Text, webBody, pageDto.CheckingType) == false)
                {
                    await PageChanged(pageDto, primaryText.Text, webBody);
                }
            }
            catch (WebException)
            {
                //TODO: LOGS
            }
        }
示例#2
0
        public async Task <IActionResult> GetDifference(Guid guid)
        {
            var diff = await _pageDifferenceService.GetDifference(guid);

            if (diff == null)
            {
                return(BadRequest());
            }
            var page = await _pageService.GetPage(diff.PageId);

            if (!page.HighAccuracy)
            {
                var websiteText = await _websiteTextService.GetText(page.PrimaryTextId);

                diff.Text = _htmlDifferenceService.Prettyfy(diff.Text, websiteText.Text, page.CheckingType);
            }

            return(Ok(diff));
        }