コード例 #1
0
        public IActionResult Find(FindModel model)
        {
            var web          = new HtmlWeb();
            var originalDoc  = web.Load(model.OriginUrl);
            var originalNode = originalDoc.GetElementbyId(model.OriginId);

            if (originalNode == null)
            {
                throw new Exception("Element not found");
            }

            var sampleDoc   = web.Load(model.SampleUrl);
            var sampleNodes = sampleDoc.DocumentNode.Descendants();

            var result = FinderService.Find(sampleNodes, originalNode);

            if (result.Element == null)
            {
                throw new Exception("No matching elements");
            }
            return(View(result));
        }