AdaptiveSelector class

A selector that can adapt to different HTML structures

Constructors

AdaptiveSelector.new({required String primarySelector, List<String> alternativeSelectors = const [], String? attribute, bool asText = true, Logger? logger})
Creates a new AdaptiveSelector with the given parameters
AdaptiveSelector.fromString(String selector, {String? attribute, bool asText = true, Logger? logger})
Creates a new AdaptiveSelector from a string
factory
AdaptiveSelector.withAlternatives({required String primarySelector, required List<String> alternativeSelectors, String? attribute, bool asText = true, Logger? logger})
Creates a new AdaptiveSelector with multiple selectors
factory

Properties

alternativeSelectors List<String>
Alternative selectors to try if the primary selector fails
final
asText bool
Whether to extract the text content of the element
final
attribute String?
The attribute to extract from the element
final
hashCode int
The hash code for this object.
no setterinherited
logger Logger?
Logger for logging selector operations
final
primarySelector String
The primary selector to try first
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

extract(String html) List<String>
Extracts data from the given HTML using this selector
extractFromDocument(Document document) List<String>
Extracts data from the given document using this selector
extractSingle(String html) String?
Extracts a single value from the given HTML using this selector
extractSingleFromDocument(Document document) String?
Extracts a single value from the given document using this selector
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
suggestAlternatives(String html) List<String>
Suggests alternative selectors based on the given HTML
suggestAlternativesFromDocument(Document document) List<String>
Suggests alternative selectors based on the given document
toString() String
A string representation of this object.
inherited
validate(String html) bool
Validates that this selector can find elements in the given HTML
validateDocument(Document document) bool
Validates that this selector can find elements in the given document

Operators

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