예제 #1
0
        public SiteCompare(string comparePath1, string comparePath2, string[] urlList, string selector, string[] excludeSelectors = null)
        {
            // TODO: Complete member initialization
            this.comparePath1 = comparePath1;
            this.comparePath2 = comparePath2;
            this.urlList = urlList;
            this.selector = selector;
            this.excludeSelectors = excludeSelectors;
            this.CompareResult = new List<SiteCompareResult>();

            foreach (var url in urlList)
            {

                var path1 = Utilities.GetFullPath(comparePath1, url);
                var path2 = Utilities.GetFullPath(comparePath2, url);

                var html1 = Utilities.GetHtmlFromFileOrUrl(path1);
                var html2 = Utilities.GetHtmlFromFileOrUrl(path2);

                var htmlDiff = new HtmlComparer(html1, html2, selector, excludeSelectors);

                this.CompareResult.Add(new SiteCompareResult
                {
                    path1 = path1,
                    path2 = path2,
                    Diffs = htmlDiff.Diffs

                });

            }

        }
예제 #2
0
        public SiteCompare(string url1, string url2, string selector)
        {
            // TODO: Complete member initialization
            this.comparePath1 = url1;
            this.comparePath2 = url2;
            this.selector = selector;
            this.CompareResult = new List<SiteCompareResult>();

            using (var client = new WebClient())
            {

                var html1 = client.DownloadString(url1);
                var html2 = client.DownloadString(url2);

                var htmlDiff = new HtmlComparer(html1, html2, selector);

                this.CompareResult.Add(new SiteCompareResult
                {
                    path1 = url1,
                    path2 = url2,
                    Diffs = htmlDiff.Diffs

                });

            }


        }