vectors

This module contains functions to convert DOM relations to path-like lists of elements defined by tag names and parameters.

harvester.autoparser.vectors.el_to_path_vector(el)[source]

Convert el to vector of foregoing elements.

Attr:
el (obj): Double-linked HTMLElement instance.
Returns:list – HTMLElements which considered as path from root to el.
harvester.autoparser.vectors.common_vector_root(vec1, vec2)[source]

Return common root of the two vectors.

Parameters:
  • vec1 (list/tuple) – First vector.
  • vec2 (list/tuple) – Second vector.

Usage example:

>>> common_vector_root([1, 2, 3, 4, 5], [1, 2, 8, 9, 0])
[1, 2]
Returns:list – Common part of two vectors or blank list.
harvester.autoparser.vectors.find_common_root(elements)[source]

Find root which is common for all elements.

Parameters:elements (list) – List of double-linked HTMLElement objects.
Returns:list – Vector of HTMLElement containing path to common root.

Previous topic

conf_reader

Next topic

path_patterns

This Page