Пример #1
0
        static void crawler_ProcessPageCrawlStarting(object sender, PageCrawlStartingArgs e)
        {
            string       childUrl     = e.PageToCrawl.Uri.AbsoluteUri;
            string       parentUrl    = e.PageToCrawl.ParentUri.AbsoluteUri;
            CrawlContext context      = e.CrawlContext;
            CrawledLinks crawledLinks = context.CrawlBag.CrawledLinks;

            crawledLinks.AddRelation(parentUrl, childUrl);
        }
Пример #2
0
        static void Main(string[] args)
        {
            PoliteWebCrawler crawler = CreateCrawler(Convert.ToInt32(args[1]), Convert.ToInt32(args[2]));

            crawler.CrawlBag.Count = 0;
            CrawledLinks crawledLinks = new CrawledLinks($"Links from {args[0]}");

            crawler.CrawlBag.CrawledLinks = crawledLinks;
            CrawlFromSeed(args[0], crawler);
            crawledLinks.GenerateReport();
            Console.WriteLine("Report Successfully generated, press any key to quit");
            Console.ReadKey();
        }