Пример #1
0
        public static Report Analyze(int reportId, string url)
        {
            Site site = new Site();
            site.mainUrl = NormalizeUrl(url);
            if (IsCorrectURL(site.mainUrl)) {
                site.content = GetContent(url);
                site.pages = GetPages(site.content, site.mainUrl);
            }
            else {
                throw new Exception("Uncorrect url");
            }

            Report report = new Report(reportId);
            report.MainUrl = site.mainUrl;
            report.RobotsTxt = CheckRobotsTxt(site.mainUrl);
            Thread.Sleep(1000);
            report.Error404 = CheckError404(site.mainUrl);
            Thread.Sleep(1000);
            report.Redirect = CheckMirror(site.mainUrl);
            report.mainPageResult = AnalyzePage(site);
            int count = 0;
            foreach (string urlPage in site.pages) {
                try {
                    Features result = AnalyzePage(GetContent(urlPage));
                    report.AddCheckedPage(result, urlPage);
                    count++;
                    if (count == MAX_CHILD_PAGE_IN_REPORT) {
                        break;
                    }
                    Thread.Sleep(1000);
                }
                catch (Exception ex) {
                    Console.WriteLine(@"method: Analyzer.Analyze()\n {0}\n,", ex.Message);
                }
            }
            return report;
        }
Пример #2
0
 // Analyze one page of site.
 //
 private static Features AnalyzePage(Site site)
 {
     return AnalyzePage(site.content);
 }