extract method

  1. @override
List extract(
  1. dynamic input
)
override

Process input and extract necessary data.

  • Note: the output is usually passed to the next extractor in the chain.

Implementation

@override
List extract(dynamic input) {
  selectMatchingElements(HtmlUtils.formatInputElement(input)).forEach((element) {
    final descAttrs = element.attributes.keys
        .map((name) => name as String)
        .where((attr) => attributes.containsKey(attr) && attributes[attr] != null)
        .where((attr) => attributes[attr]!.trim().isNotEmpty)
        .where((attr) => element.attributes[attr]!.trim().isNotEmpty)
        .toList();
    descAttrs.forEach((attr) {
      final srcAttr = attributes[attr]!;
      element.attributes[srcAttr] = element.attributes[attr]!;
    });
  });
  return [input];
}