[Crawler Learning Notes] URL Filter Module Urlfilter

Source: Internet
Author: User

The URL filter filters the extracted URLs again. Different application filtering criteria are not the same, for example, for Baidu/google search, generally do not filter, but for vertical search or targeted crawl of the application, it may only need to meet a certain condition of the URL, such as do not need the image of the URL, such as the need for a specific site URL, and so on. The URL filter is a module that is closely related to the application.

usingSystem;usingSystem.Collections.Generic;usingCrawler.common;namespacecrawler.processing{ Public classUrlfilter { Public StaticList<uri> Removebyregex (list<uri> URIs,params string[] regexs) {            varurilist=NewList<uri>(URIs);  for(vari =0; i < Urilist.count; i++)            {                foreach(varRinchRegexs) {                    if(! Regexhelper.ismatch (Urilist[i]. ToString (), R))Continue; URIs.                    RemoveAt (i); I--; }            }            returnurilist; }         Public StaticList<uri> Selectbyregex (list<uri> URIs,params string[] regexs) {            varUrilist =NewList<uri>(); foreach(varTinchURIs)foreach(varRinchRegexs)if(Regexhelper.ismatch (T.tostring (), R))if(!urilist.contains (t)) Urilist.add (t); returnurilist; }    }}

[Crawler Learning Notes] URL Filter Module Urlfilter

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.