Parser class

Defines how to extract specific data from HTML or other sources.

A parser is a configuration block that specifies:

  • What type of data to extract (text, elements, images, etc.)
  • Where to find the data (CSS selectors, XPath, etc.)
  • How to process the extracted data (transformations, cleaning)
  • When to execute the parser (parent-child relationships)
  • Whether the result should be public or private

Parsers can be organized in a hierarchy where child parsers depend on their parent parsers' output, enabling complex nested data extraction.

Constructors

Parser.new({required String id, required List<String> parents, required ParserType type, List<String> selectors = const [], bool isPrivate = false, bool multiple = false, ParserOptions? parserOptions, TransformationOptions? transformationOptions, CleanerFunction? cleaner, String? cleanerName})
Creates a new Parser instance.
Parser.fromJson(String json)
Creates a Parser instance from a JSON string.
factory
Parser.fromMap(Map<String, dynamic> map)
Creates a Parser instance from a Map.
factory

Properties

cleaner CleanerFunction?
Custom cleaning function to process extracted data.
getter/setter pair
cleanerName String?
Name of the registered cleaner function for serialization.
getter/setter pair
hashCode int
The hash code for this object.
no setterinherited
id String
Unique identifier for this parser's output.
getter/setter pair
isPrivate bool
Whether this parser's output should be kept private.
getter/setter pair
multiple bool
Whether this parser can extract multiple results.
getter/setter pair
parents List<String>
List of parent parser IDs that this parser depends on.
getter/setter pair
parserOptions ParserOptions?
Parser-specific configuration options that control how the parser behaves.
getter/setter pair
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
selectors List<String>
CSS selectors used to locate elements in the HTML.
getter/setter pair
transformationOptions TransformationOptions?
Data transformation options to apply after extraction.
getter/setter pair
type ParserType
The type of parser that determines how data is extracted.
getter/setter pair

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toJson() String
Converts the Parser instance to a JSON string.
toMap() Map<String, dynamic>
Converts the Parser instance to a Map.
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited