woob.browser.elements
¶
- class AbstractElement(*args, **kwargs)[source]¶
Bases:
object
-
condition:
None
|bool
|_Filter
|Callable
[[],Any
] = None¶ The condition to parse the element.
This allows ignoring certain elements if certain fields are not valid, or if the element should actually be parsed using another class.
This property can be defined as:
None or True, to signify that the element should be parsed regardless.
False, to signify that the element should not be parsed regardless.
A filter returning a falsy or non-falsy object, evaluated with the constructed document section (HTML element or JSON data) for the element.
A method returning a falsy or non-falsy object, evaluated with the element object directly.
-
condition:
- class DictElement(*args, **kwargs)[source]¶
Bases:
ListElement
- class ItemElement(*args, **kwargs)[source]¶
Bases:
AbstractElement
-
item_xpath:
str
|None
= None¶ The xpath to reroot the element in.
This will be evaluated only once the object and environment are set, so it can be defined as a property using
self.obj
andself.env
, i.e. call parameters.
-
item_xpath:
- class ItemElementFromAbstractPage[source]¶
Bases:
object
Don’t use this class, import woob_modules.other_module.etc instead
- class ListElement(*args, **kwargs)[source]¶
Bases:
AbstractElement
- item_xpath = None¶
- empty_xpath = None¶
- flush_at_end = False¶
- ignore_duplicate = False¶
- exception SkipItem[source]¶
Bases:
Exception
Raise this exception in an
ItemElement
subclass to skip an item.
- class TableElement(*args, **kwargs)[source]¶
Bases:
ListElement
- head_xpath = None¶
- generate_table_element(doc, head_xpath, cleaner=CleanText)[source]¶
Prints generated base code for TableElement/TableCell usage. It is intended for development purposes, typically in woob-debug. :type doc: :param doc: lxml tree of the page (e.g. browser.page.doc) :type head_xpath: :param head_xpath: xpath of header columns (e.g. //table//th) :type head_xpath: str :type cleaner: :param cleaner: cleaner class (Filter) (default:
CleanText
) :type cleaner: Filter