Skip to main content

HandleMemory

ClassSource

HandleMemory[_Tag](process_func: Callable[[dict[str, Any], str, _Tag], _Tag | None])

Temporary memory designed for parsing the data that may need to handle children by customized methods and record special information.

Arguments​

Requires​

NameTypeRequired
Description
process_funcCallable[[dict[str, Any], str, _Tag], _Tag | None]

A scope-limited processor function.

The input arguments are:

  1. storage: The storage provided by this memory. It is mutable and allows users to store data during the process_func.
  2. name: The node name pre-processed by str.casefold.
  3. node: The bs4 tag node that allows users to extract the data from the node.

It will return the argument node if the node should be passed to further parsing steps. If it returns None, this node will be dropped during the parsing.

Methods​

process​

v_1: _Tag | None = self.process(name: str, node: _Tag)

Run the processing for a specific tag node.

Requires​

NameTypeRequired
Description
namestrEquivalent to tag.name.casefold()
node_TagThe HTML tag node that would be used for catching the data.

Returns​

NameType
Description
v_1_Tag | NoneReturn Tag if it should be further parsed. If this value is None, the given node (including its children) will be dropped in the parsed results.