woob.browser.filters.base

class woob.browser.filters.base.Filter(selector=None, default=NO_DEFAULT)

Bases: woob.browser.filters.base._Filter

Class used to filter on a HTML element given as call parameter to return matching elements.

Filters can be chained, so the parameter supplied to constructor can be either a xpath selector string, or an other filter called before.

>>> from lxml.html import etree
>>> f = CleanDecimal(CleanText('//p'), replace_dots=True)
>>> f(etree.fromstring('<html><body><p>blah: <span>229,90</span></p></body></html>'))
Decimal('229.90')
Parameters

default – default value in case the filter fails to find or parse the requested value

filter(value)

This method has to be overridden by children classes.

select(selector, item)
exception woob.browser.filters.base.FilterError

Bases: woob.exceptions.ParseError

exception woob.browser.filters.base.ItemNotFound

Bases: woob.browser.filters.base.FilterError