How to use the icrawler.builtin.filter.Filter function in icrawler

To help you get started, we’ve selected a few icrawler examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github hellock / icrawler / icrawler / builtin / bing.py View on Github external
def get_filter(self):
        search_filter = Filter()

        # type filter
        def format_type(img_type):
            prefix = '+filterui:photo-'
            return (prefix + 'animatedgif'
                    if img_type == 'animated' else prefix + img_type)

        type_choices = [
            'photo', 'clipart', 'linedrawing', 'transparent', 'animated'
        ]
        search_filter.add_rule('type', format_type, type_choices)

        # color filter
        def format_color(color):
            prefix = '+filterui:color2-'
            if color == 'color':
github hellock / icrawler / icrawler / builtin / google.py View on Github external
def get_filter(self):
        search_filter = Filter()

        # type filter
        def format_type(img_type):
            return ('itp:lineart'
                    if img_type == 'linedrawing' else 'itp:' + img_type)

        type_choices = ['photo', 'face', 'clipart', 'linedrawing', 'animated']
        search_filter.add_rule('type', format_type, type_choices)

        # color filter
        def format_color(color):
            if color in ['color', 'blackandwhite', 'transparent']:
                code = {
                    'color': 'color',
                    'blackandwhite': 'gray',
                    'transparent': 'trans'
github hellock / icrawler / icrawler / builtin / baidu.py View on Github external
def get_filter(self):
        search_filter = Filter()

        # type filter
        type_code = {
            'portrait': 's=3&lm=0&st=-1&face=0',
            'face': 's=0&lm=0&st=-1&face=1',
            'clipart': 's=0&lm=0&st=1&face=0',
            'linedrawing': 's=0&lm=0&st=2&face=0',
            'animated': 's=0&lm=6&st=-1&face=0',
            'static': 's=0&lm=7&st=-1&face=0'
        }

        def format_type(img_type):
            return type_code[img_type]

        type_choices = list(type_code.keys())
        search_filter.add_rule('type', format_type, type_choices)