sjdirect / abot

Cross Platform C# web crawler framework built for speed and flexibility. Please star this project! +1.
Apache License 2.0
2.23k stars 555 forks source link

How to implement the decision maker function #216

Closed kunal0810 closed 4 years ago

kunal0810 commented 4 years ago

I am working on project where before crawling a page i need to check whether should a crawl this page or not. i have tried using the shouldcrawlpagedecisionmaker and does not get the right way to implement that.

can someone please help to get it correct. Displaying image.png image

sjdirect commented 4 years ago

Apologies, the doc snippet was using a no longer supported method. Switch it to a property instead as the example below. I also updated the readme doc.

crawler.ShouldCrawlPageDecisionMaker = (pageToCrawl, crawlContext) => 
{
    var decision = new CrawlDecision{ Allow = true };
    if(pageToCrawl.Uri.Authority == "google.com")
        return new CrawlDecision{ Allow = false, Reason = "Dont want to crawl google pages" };

    return decision;
};