NCrawler 开源爬虫框架学习

来源:互联网 发布:广电网络云平台 编辑:程序博客网 时间:2024/05/17 18:45

开源爬虫的框架很多,不过对于使用者来说最最简单的应该是 NCrawler了。

该框架是基于C# 语言的。 依据其demo 代码,即使未学习过c# ,也可以在10分钟内生成属于自己的爬虫代码。

 

只需要将下面的uri替换为你需要的uri即可。

   using (Crawler c = new Crawler(new Uri("http://blog.csdn.net/"),
    new HtmlDocumentProcessor(), // Process html
    //new iTextSharpPdfProcessor.iTextSharpPdfProcessor(), // Add PDF text extraction
   // new GoogleLanguageDetection(), // Add language detection
    //new Mp3FileProcessor(), // Add language detection
    new DumperStep())
    {
     // Custom step to visualize crawl
     MaximumThreadCount = 2,
     MaximumCrawlDepth = 6,
     //ExcludeFilter = Program.ExtensionsToSkip,
      

    })
   {


    // Begin crawl
    c.Crawl();
   }

0 0
原创粉丝点击